how to redirect users to a custom page when they click on their display name or nickname?

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.

Answers


using jQuery you can do:

<script type="text/javascript">
    $('#display_name_button_id').click(function(e) {
        e.preventDefault();
        e.stopPropagation();
        window.location = 'link-to-custom-page.html';
    });
</script>

Need Your Help

XAML element binding between 2 files?

c# wpf xaml binding

Suppose I have a two textboxes in the same XAML file. I want the input in textbox 2 to come from whatever I type in textbox 1.