function restrict_access_admin_panel(){ global $current_user; if ($current_user->user_level < 4) { wp_redirect( home_url() ); exit; } } add_action('admin_init', 'restrict_access_admin_panel', 1);