php怎么显示用户的注册日期,WordPress 后台用户列表显示用户注册时间

/**

* WordPress 后台用户列表显示注册时间

* https://www.wpdaxue.com/display-user-registerdate.html

*/

class RRHE {

// Register the column - Registered

public static function registerdate($columns) {

$columns['registerdate'] = __('注册时间', 'registerdate');

return $columns;

}

// Display the column contentpublic static function registerdate_columns( $value, $column_name, $user_id ) {if ( 'registerdate' != $column_name )return $value;$user = get_userdata( $user_id );$registerdate = get_date_from_gmt($user->user_registered);return $registerdate;}

public static function registerdate_column_sortable($columns) {

$custom = array(

// meta column id => sortby value used in query

'registerdate' => 'registered',

);

return wp_parse_args($custom, $columns);

}

public static function registerdate_column_orderby( $vars ) {

if ( isset( $vars['orderby'] ) && 'registerdate' == $vars['orderby'] ) {

$vars = array_merge( $vars, array(

'meta_key' => 'registerdate',

'orderby' => 'meta_value'

) );

}

return $vars;

}

}

// Actions

add_filter( 'manage_users_columns', array('RRHE','registerdate'));

add_action( 'manage_users_custom_column', array('RRHE','registerdate_columns'), 15, 3);add_filter( 'manage_users_sortable_columns', array('RRHE','registerdate_column_sortable') );

add_filter( 'request', array('RRHE','registerdate_column_orderby') );

/**

* WordPress 后台用户列表显示注册时间

* https://www.wpdaxue.com/display-user-registerdate.html

*/

class RRHE {

// Register the column - Registered

public static function registerdate($columns) {

$columns['registerdate'] = __('注册时间', 'registerdate');

return $columns;

}

// Display the column content

public static function registerdate_columns( $value, $column_name, $user_id ) {

if ( 'registerdate' != $column_name )

return $value;

$user = get_userdata( $user_id );

$registerdate = get_date_from_gmt($user->user_registered);

return $registerdate;

}

public static function registerdate_column_sortable($columns) {

$custom = array(

// meta column id => sortby value used in query

'registerdate' => 'registered',

);

return wp_parse_args($custom, $columns);

}

public static function registerdate_column_orderby( $vars ) {

if ( isset( $vars['orderby'] ) && 'registerdate' == $vars['orderby'] ) {

$vars = array_merge( $vars, array(

'meta_key' => 'registerdate',

'orderby' => 'meta_value'

) );

}

return $vars;

}

}

// Actions

add_filter( 'manage_users_columns', array('RRHE','registerdate'));

add_action( 'manage_users_custom_column', array('RRHE','registerdate_columns'), 15, 3);

add_filter( 'manage_users_sortable_columns', array('RRHE','registerdate_column_sortable') );

add_filter( 'request', array('RRHE','registerdate_column_orderby') );

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值