Wordpress后台用户显示注册时间
在主题的 functions.php 里添加下面的代码:
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') );
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。