【问题标题】:Redirect Specific User重定向特定用户
【发布时间】:2014-10-17 09:09:30
【问题描述】:

我需要将特定用户重定向到特定页面。这是一个隐藏页面,我希望只有他在登录时才能访问它。我已经设法在页面上添加了 WordPress 登录。我希望用户通过它登录。

我试过Peter's login redirect,因为它是唯一一个为特定用户提供规则的插件。

【问题讨论】:

  • 不幸的是,您需要提供一些代码来显示尝试至少解决您的问题。简单地要求人们为你做这项工作会导致一波又一波的反对票,而且没有人愿意提供帮助。
  • 嗯,我喜欢这篇文章,它就是答案。谢谢。

标签: php wordpress redirect


【解决方案1】:

感谢所有回复的人。

让它与以下功能一起使用。 http://codex.wordpress.org/Function_Reference/wp_get_current_user

从上面得到信息.. 下面是代码。在主题function.php上添加了这个。

function redirect_specified_user()
    {
    global $current_user;
    get_currentuserinfo();

    // User 1
    $specific_user1 = "test12";
    $specific_user1_Url = "http://www.yoursite.com/anywhere/";

    // Specify Users Functions
    if ($current_user->user_login == $specific_user1)
    {
        wp_redirect( $specific_user1_Url ); exit;
    }
    }
add_action('admin_init', 'redirect_specified_user');

【讨论】: