Intro
By default, all logged in WordPress users have at least some access to the dashboard. In order to prevent anyone but admins to the dashboard, there are steps you can take.
Background
There is an article here which gives several different methods of selected access to the dashboard.
Limit Access via Code
To block all users except admins from your dashboard, just add the following code at the end of your functions.php file:
/* Redirect anyone but admin from accesing dashboarrd and send them to the homepage. */
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( ! current_user_can( 'administrator' ) ) {
If ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}
}

Leave a Reply