php - Sorting custom Column in users section not working fine in wordpress -
i using code sort users list in admin/users. not working still sorting on basis of user name , email(default worpress sorting columns) how can sort users list on basis of custom user meta key , value "store_name" , not default word press columns.
code till now
// register column sortable function store_name_column_register_sortable($columns) { $columns['store_name'] = 'store_name'; return $columns; } add_filter('manage_users_sortable_columns', 'store_name_column_register_sortable'); function store_name_column_orderby($vars) { if (isset($vars['orderby']) && 'store_name' == $vars['orderby']) { $vars = array_merge($vars, array( 'meta_key' => 'store_name', 'orderby' => 'meta_value' )); } return $vars; } add_filter('request', 'store_name_column_orderby');
add order=>'asc' or 'desc'
function store_name_column_register_sortable( $columns ) { $columns['store_name'] = 'store_name'; return $columns; } add_filter( 'manage_users_sortable_columns', 'store_name_column_register_sortable' ); function store_name_column_orderby( $vars ) { if ( isset( $vars['orderby'] ) && 'company' == $vars['orderby'] ) { $vars = array_merge( $vars, array( 'meta_key' => 'company', 'orderby' => 'meta_value', 'order' => 'asc' ) ); } return $vars; } add_filter( 'request', 'store_name_column_orderby' );
Comments
Post a Comment