They aren’t sortable columns. So are you just adding the query args to the URL manually? If so, that’s not going to sort anything.
If you’ve applied some customization to do sorting of the user table, then you need to make sure it sorts by the value given. In the case of the user IP, it’s a meta field. For the user ID, it’s not; it’s a wp_user field.
sorry for goatrope, those are the columns’ headers’ links… i found this in my functions.php:
/*
- Make our “Registration date” column sortable
- @param array $columns Array of all user sortable columns {column ID} => {orderby GET-param}
*/
add_filter( ‘manage_users_sortable_columns’, ‘rudr_make_registered_column_sortable’ );
function rudr_make_registered_column_sortable( $columns ) {
return wp_parse_args( array(
‘user_registered’ => ‘user_registered’,
‘wpmem_reg_ip’ => ‘wpmem_reg_ip’,
‘user_id’ => ‘user_id’
), $columns );
}
which seems to be part of https://rudrastyh.com/wordpress/sortable-date-user-registered-column.html
chatgpt reveals that i’m missing pre_get_users to patch the query for meta sort, but that doesn’t explain why user_id is fupduck, or why user_registered works when the sortable key is ‘registered’ not ‘user_registered’
If all you’re doing is what is at this guy’s code snippet and adding the custom columns you noted above, user_registered and registered shouldn’t make a difference, so I’m not sure why you would have a different result between the two.
The problem you’re having with the ID is because that code snippet is extending the existing WP_List_Table class, which as some already built in stuff. So unless you add in your own sort, passing user_id makes it try to sort by that value – but that isn’t value in the WP_User object. It’s ID. Your array key/value pair needs to be:
'user_id' => 'ID'
-
This reply was modified 1 day, 1 hour ago by
Chad Butler.