How to redirect users to a custom page when they click on their display name or my profile or dashboard on my WordPress site. Because I locked /wp-admin
with this
add_action('admin_init', 'no_mo_dashboard');
function no_mo_dashboard() {
global $wp_query;
if (!current_user_can('manage_options') && $_SERVER['DOING_AJAX'] != '/wp-admin/admin-ajax.php') {
$wp_query->set_404();
status_header( 404 );
get_template_part( 404 ); exit();
}
}
and an user gets 404 error if requests mydoimain/wp-admin
. But the problem is when an user clicks on his display name it returns 404 error. So in nutshell what I want is that when an user request for mydomain/wp-admin
should get 404 but when the user clicks on his display name or "my profile" or dashboard gets redirected any custom page on front-end. Anyone please help.