教程说明
代码插入到/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']."";
}
});
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容