Let's say I want to disable users from viewing the dashboard.
I can add the following to functions.php
:
function hide_dashboard_init() {
if ( is_admin() && !current_user_can( 'manage_options' ) ) {
wp_redirect( home_url() );
exit;
}
}
add_action( 'init', 'hide_dashboard_init' );
But why not just add a regular function to functions.php
? Something like that:
function hide_dashboard() {
if ( is_admin() && !current_user_can( 'manage_options' ) ) {
wp_redirect( home_url() );
}
}