If you’re still struggling with this issue, you might want to check out this article:
https://wordpress.stackexchange.com/questions/20639/sortable-columns-on-a-custom-post-type-wont-work
I’m using a registration plugin that creates meta-data (e.g. company name, title) and was able to hack code from the article and get sortable columns on my users.php page:
function user_sortable_columns( $columns ) {
$columns['company'] = 'Company';
return $columns;
}
add_filter( 'manage_users_sortable_columns', 'user_sortable_columns' );
function user_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', 'user_column_orderby' );
While it doesn’t appear thoroughly documented anywhere, apparently there is a manage_users_sortable_columns filter. Indeed, the “users” part apparently could be post or a custom content type name.
The only issue I had was matching the column names I defined for each of my user custom columns for user.php and, once figured out, the code worked immediately, on any custom column. If it is useful, here is that code (which is placed above the code that orders these columns):
//add columns to User panel list page
function add_user_columns( $defaults ) {
$defaults['company'] = __('Company', 'user-column');
$defaults['title'] = __('Title', 'user-column');
return $defaults;
}
function add_custom_user_columns($value, $column_name, $id) {
if( $column_name == 'company' ) {
return get_the_author_meta( 'company_name', $id );
}
if( $column_name == 'title' ) {
return get_the_author_meta( 'titlefunction', $id );
}
}
add_action('manage_users_custom_column', 'add_custom_user_columns', 15, 3);
add_filter('manage_users_columns', 'add_user_columns', 15, 1);
The name of the author_meta value is set in the registration plugin I’m using.
Hope that helps!