wordpress - 使 "Add New User"重定向到用户的个人资料

标签 wordpress

我想知道是否有可能当您创建一个新用户 user-new.php 时,您会被重定向到用户的个人资料而不是 users.php

我有一些自定义字段只在您编辑用户时显示,所以为了使工作流程更简单,我希望管理员能够重定向到用户的个人资料,以便他可以添加这些自定义字段会立即出现。

最佳答案

wp_redirectfilterable ,因此您可以在成功添加用户后进行重定向。我测试了以下内容,可能需要进行一些调整,但它确实有效:

add_filter( 'wp_redirect', 'wp_redirect_after_user_new', 1, 1 );
function wp_redirect_after_user_new( $location )
{
    global $pagenow;

    if( is_admin() && 'user-new.php' == $pagenow )
    {
        $user_details = get_user_by( 'email', $_REQUEST[ 'email' ] );
        $user_id = $user_details->ID;

        if( $location == 'users.php?update=add&id=' . $user_id )
            return add_query_arg( array( 'user_id' => $user_id ), 'user-edit.php' );
    }

    return $location;
}

关于wordpress - 使 "Add New User"重定向到用户的个人资料,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16352855/

相关文章:

javascript - 检查字符串是否包含任何字母(Javascript/jquery)

wordpress - NGINX+Wordpress 缓存悖论

php - 提交后如何停止重新加载页面?

wordpress - 如何在 WordPress 的页脚前添加文本?

css - div block 中的内容在移动设备中消失了吗?

php - 自定义账单/发货表单中的占位符

php - 如何在 sql 查询 VALUES 中包含分号?

php - 如何在提交联系表单后重定向到感谢页面 - Wordpress 高级主题联系我们 php 模板

php - 根据季节/时间为 body 添加类(class)

PHP 显示列值的总和结果