WordPress注册用户如何按注册时间排序?

一、打开functions.php 文件吧下列代码放到底部即可!

add_filter(‘manage_users_columns’,’wpjam_add_users_column_reg_time’);
function wpjam_add_users_column_reg_time($column_headers){
$column_headers[‘reg_time’] = ‘注册时间’;
return $column_headers;
}

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

add_filter( “manage_users_sortable_columns”, ‘wpjam_users_sortable_columns’ );
function ys_users_sortable_columns($sortable_columns){
$sortable_columns[‘reg_time’] = ‘reg_time’;
return $sortable_columns;
}
add_action( ‘pre_user_query’, ‘wpjam_users_search_order’ );
function wpjam_users_search_order($obj){
if(!isset($_REQUEST[‘orderby’]) || $_REQUEST[‘orderby’]==’reg_time’ ){
if( !in_array($_REQUEST[‘order’],array(‘asc’,’desc’)) ){
$_REQUEST[‘order’] = ‘desc’;
}
$obj->query_orderby = “ORDER BY user_registered “.$_REQUEST[‘order’].””;
}
}

 

————下载必看————

1、资源通过互联网渠道公开获取,仅供阅读测试,请在下载后24小时内删除,谢谢合作!
2、若版权方认为本站侵权,请联系发邮件至(rsstime@qq.com)处理。
3、本站解压密码统一为:yudouyudou

时光屋 » WordPress注册用户如何按注册时间排序?

发表评论

至臻视听_发烧收藏

会员介绍 常见问题