Users & Login PHP Beginner

Add a Sortable Registered Date Column to Users

Show when each user signed up in the Users list, and click the column to sort newest or oldest first.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 17 lines
add_filter( 'manage_users_columns', function ( array $columns ): array {
	$columns['nahnu_registered'] = 'Registered';
	return $columns;
} );

add_filter( 'manage_users_custom_column', function ( string $output, string $column, int $user_id ): string {
	if ( 'nahnu_registered' !== $column ) {
		return $output;
	}
	$user = get_userdata( $user_id );
	return $user ? esc_html( wp_date( get_option( 'date_format' ), strtotime( $user->user_registered ) ) ) : '';
}, 10, 3 );

add_filter( 'manage_users_sortable_columns', function ( array $columns ): array {
	$columns['nahnu_registered'] = 'registered';
	return $columns;
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

The Users screen doesn’t show when people joined, which is often the first thing you want to know when checking new sign-ups or spam accounts. This snippet adds a Registered column you can sort by.

How it works

manage_users_columns adds the column header and manage_users_custom_column fills in each row from the user’s user_registered date, formatted with your site’s date format.
manage_users_sortable_columns makes the header clickable. Mapping it to registered, a field WordPress already knows how to sort by, means no extra query code is needed.

Things to watch

  • Registration dates are stored in UTC. wp_date() shows them in your site’s time zone.

How to test it

Go to Users. You should see a Registered column. Click its header to sort.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only