dongtong848825 2014-01-28 16:53
浏览 48
已采纳

如何在用户点击显示名称或昵称时将用户重定向到自定义页面?

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.

  • 写回答

1条回答 默认 最新

  • dongluo8439 2014-01-28 16:59
    关注

    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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题