Home » Wordpress » How to restrict user other than administrator to acess wp-admin in wordpress

Here is code restrict user other than administrator to acess wp-admin in wordpress.
Put below code into your theme/funtion.php file

function block_wp_admin_init() {

if (strpos(strtolower($_SERVER['REQUEST_URI']),'/wp-admin/') !== false) {
  if ( !is_site_admin() ) {
     wp_redirect( get_option('siteurl'), 302 );
  }
}
}
add_action('init','block_wp_admin_init',0);

Array ( [0] => Wordpress )