Show the Newest Users First in the Users List
Sorts the Users screen by registration date with the newest accounts on top by default, so new sign-ups are easy to review.
Opens WPIDE on
Code
add_action( 'pre_get_users', function ( $query ) {
global $pagenow;
if ( 'users.php' !== $pagenow || ! empty( $_GET['orderby'] ) || $query->get( 'fields' ) === 'ID' ) {
return;
}
$query->set( 'orderby', 'registered' );
$query->set( 'order', 'DESC' );
} );
Notes
Clicking a column header still sorts by that column.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.