直接上代码把

代码插入到/wp-content/themes/您正在使用的主题目录/functions.php

例如RiPro:/wp-content/themes/ripro/functions.php

//用户注册时间排序
add_filter('manage_users_columns', function($column_headers){
	$column_headers['registered'] = '注册时间';
	return $column_headers;
});

add_filter('manage_users_custom_column', function($value, $column_name, $user_id){
	if($column_name=='registered'){
		$user = get_userdata($user_id);
		return get_date_from_gmt($user->user_registered);
	}else{
		return $value;
	}
},11,3);


add_filter('manage_users_sortable_columns', function($sortable_columns){
	$sortable_columns['reg_time'] = 'reg_time';
	return $sortable_columns;
});

add_action('pre_user_query', function($query){
	if(!isset($_REQUEST['orderby']) || $_REQUEST['orderby']=='reg_time' ){
		if( !in_array($_REQUEST['order'],array('asc','desc')) ){
			$_REQUEST['order'] = 'desc';
		}
		$query->query_orderby = "ORDER BY user_registered ".$_REQUEST['order']."";
	}
});
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。