The easiest solution is to hook in load-index.php
and redirect non-admin users to their profile. Effectively blocking access to that page. I’m going to wrap the permission check up in a function for this example (we’ll use it more than once).
function _wpse206466_can_view()
{
// or any other admin level capability
return current_user_can('manage_options');
}
add_action('load-index.php', 'wpse206466_load_index');
function wpse206466_load_index()
{
if (!_wpse206466_can_view()) {
$qs = empty($_GET) ? '' : '?'.http_build_query($_GET);
wp_safe_redirect(admin_url('profile.php').$qs);
exit;
}
}
You might also want to remove the admin index page from the admin menu if the users can’t access it. To do that, hook into admin_menu
, check the capability then remove the page.
add_action('admin_menu', 'wpse206466_remove_index');
function wpse206466_remove_index()
{
if (!_wpse206466_can_view()) {
remove_menu_page('index.php');
}
}
Here is all that as a plugin.