Restrict other users to access admin area or only admin can access the admin area:

function restrict_admin(){
if( !current_user_can('manage_options') && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] ){
//redirect to home page
wp_redirect( site_url() );
}
}
add_action('admin_init', 'restrict_admin', 1);
Advertisements