I added this to my functions.php file to disable wp-admin access for subscribers. Right now it redirects subscribers to the front page and I'd like to redirect users to the browser's stock 404. I can change the redirection to a page that doesn't exist...
wp_redirect(home_url('/fakepage'));
...which will take the user to the browser's stock 404 but that non-existent page will show in the URL.
/**
* Disable wp-admin access for subscribers
*/
function disable_dashboard() {
if (!is_user_logged_in()) {
return null;
}
if (!current_user_can('administrator') && is_admin()) {
wp_redirect(home_url());
exit;
}
}
add_action('admin_init', 'disable_dashboard');