php - 添加新的 WordPress 用户列会导致另一列为空

标签 php wordpress user-registration

我目前正在使用“最近注册”插件 ( https://wordpress.org/plugins/recently-registered/ ),该插件显示客户注册的日期并允许我订购。

我想显示新的电话号码列,但现在使用我的代码会使注册日期列空白。

常见问题解答指出:

“为什么该字段为空?

因为其他一些插件是_doing_it_wrong()。当他们创建专栏时,他们忘记让过滤器返回之前的内容(如果不是他们的专栏),因此会将其删除。由于我的插件做得很好,因此我给了它更高的优先级,以阻止大多数情况下发生这种情况。”

我不知道如何返回之前的内容。我的代码是:

function new_contact_methods( $contactmethods ) {
    $contactmethods['billing_phone'] = 'Phone Number';
    return $contactmethods;
}
add_filter( 'user_contactmethods', 'new_contact_methods', 10, 1 );


function new_modify_user_table( $column ) {
    $column['billing_phone'] = 'Phone';
    return $column;
}
add_filter( 'manage_users_columns', 'new_modify_user_table' );

function new_modify_user_table_row( $val, $column_name, $user_id ) {
    $user = get_userdata( $user_id );
    switch ($column_name) {
        case 'billing_phone' :
            return get_the_author_meta( 'billing_phone', $user_id );
            break;
        default:
    }
    return $return;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );

如果有人能提供帮助,我将不胜感激。我使用 ['billing_phone'] 作为注册过程的一部分来获取电话号码。

在“最近注册”插件中,有过滤器:

add_filter( 'manage_users_columns', array('RRHE','registerdate'));
    add_action( 'manage_users_custom_column',  array('RRHE','registerdate_columns'), 10, 3);
    add_filter( 'manage_users_sortable_columns', array('RRHE','registerdate_column_sortable') );
    add_filter( 'request', array('RRHE','registerdate_column_orderby') );

我需要确保返回所有数据。

谢谢

最佳答案

现在已经通过编辑 new_modify_user_table_row 函数解决了这个问题,该函数默认返回 $return。 $return 变量未设置,因此它返回一个空白条目。

我已将 $return 更改为 $val,这已经起作用了。

关于php - 添加新的 WordPress 用户列会导致另一列为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28189731/

相关文章:

php - 安装 pear 包后,OS X mysql 无法连接 ERROR 2002 (HY000)。使用 XAMPP

wordpress - 我想在使用 wp_trim_words 时允许 html 标签

php - 使用 ID 作为身份验证哈希

php file_get_contents 不发送所有参数

php - 片段数据库不工作 - PHP 截断 HTML

php - Symfony 登录身份验证返回错误 : Call to a member function toArray() on a non-object

css - Wordpress 中的菜单按钮/文本与粘性菜单未对齐

javascript - WooCommerce - 根据自定义字段添加费用

html - 如何避免浏览器在我的注册表中预填充字段?

ios - 使用 Openfire 中的用户服务通过 iOS 的 xmpp 框架注册新用户