Add a Sortable User Registration Date Column to All Users Page

There are could be different situations in WordPress when you will need to sort users by registration date. For example you may notice that spam users has been registered recently on your website and it is kind of difficult to find them in your users list because by default it is sorted alphabetically.

In this tutorial we are about to create a “Registration date” column just like on the screenshot below and of course, what is most important we are going to make it sortable.

this is how to sort users by registration date in WordPress admin
On this screenshot the default Posts column is hidden, but the Registration Date column is added. And when you click on its title, the users in this table will be sorted by their registration date — descending or ascending (click the title twice).

In order to implement this feature we don’t need to use any plugins (but we could of course), all we need to do is to use three WordPress filter hooks:

Let’s get started!

If you don’t know where to insert the code from this tutorial, please check this guide.

/*
 * Creating a column (it is also possible to remove some default ones)
 */
add_filter( 'manage_users_columns', 'rudr_modify_user_table' );
function rudr_modify_user_table( $columns ) {
	
	// unset( $columns['posts'] ); // maybe you would like to remove default columns
	$columns[ 'registration_date' ] = 'Registration date'; // add new
	return $columns;

}

/*
 * Fill our new column with registration dates of the users
 */
add_filter( 'manage_users_custom_column', 'rudr_modify_user_table_row', 10, 3 );
function rudr_modify_user_table_row( $row_output, $column_id_attr, $user ) {
	
	$date_format = 'j M, Y H:i';

	switch( $column_id_attr ) {
		case 'registration_date' : {
			return date( $date_format, strtotime( get_the_author_meta( 'registered', $user ) ) );
			break;
		}
		default : {
			break;
		}
	}

	return $row_output;

}

/*
 * Make our "Registration date" column sortable
 */
add_filter( 'manage_users_sortable_columns', 'rudr_make_registered_column_sortable' );
function rudr_make_registered_column_sortable( $columns ) {
	
	return wp_parse_args( array( 'registration_date' => 'registered' ), $columns );
	
}

Some notes:

If the column haven’t appeared in your WordPress admin area on the Users > All Users page or maybe you would like to hide the other columns without code — try to use “Screen Options” tab then.

Screen options of the Users Page in WordPress admin
You can hide or show specific columns using “Screen Options”.

If you have any questions left I’m ready to help you in comments.

Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X