WordPress 后台,用户是按照用户名排序的,并且没有显示注册时间,那么 WordPress 后台如何查看当天用户注册数量,并且按照注册时间排序教程呢?网站居然开启了会% | 2 y Z Y p M员制,如果我们希望能够在后台看到用户的注册时间,并且按照注册时间排序,这b 2 r :玩意儿一段代码即可搞定,其实也挺简单的就修改 1 个文件,可以通过在当前主题的 functions.php 文件添加如下面的代码即可:
- /e t q [ % W 6 z Y/用户注册时间排序
- add_filter('manage_users_columns', function($column_headers){
- $colb x f ^ ~ 2 ` $ !umn_headersS & e . \ $ s091;'registered'] = '注册时间';
- return $column_headers;
- });
- add_filter('manage_users_custom_column', funci : _ (tion($value& = 5 D q i g u -, $column_name, $user_id){
- ie + V j R G Xf($column_name=='registered')J D = ^ \ *3;
- $u^ k 3 n ] . 0 4 user = get_userdata($user_id);
- return get_date_from_gmt($user->user_registered);
- }eli ` 6 & } B Kse{
- return $value;
- }
- },11,3);
- add_filter('manage_users_sortable_columns', function($sortable_columns){
- $sorta7 } oble_columns['reg_time'] = 'r$ z K @ V 3 b X Teg_timeF n x | q ,';
- return $sortable_columns;
- });
- add_a7 g b . C Yction('pre_user_query', function($que~ x Y i 8 Ary){
- if(!isset($_ B ( + g 4 c a [_REQUEST['orderby']) || $_REQUj d ; : 4 tEST['orderby']=='reg_time' ){
- if( !in_array($_REQUEST['order'],array('asch \ m $','desc')) ){
- $_REQUEST4 _ f ,091;'ordp z H E 8 `er'] = 'desC V Yc';
- }
- $query->query_orderby = "ORDER BY user_registered ".$_REQUEST['order'&B { + . H#093;."";
- }
- });