Discover in this tutorial how to add a sortable column with the creation date in the WordPress users page.
The WordPress users page does not show the registration date of the users and sometimes it can be handy to have it available and even be able to sort them based on this parameter.
I have needed it on more than one occasion.
Luckily, WordPress allows you to add sortable columns to users thanks to the
manage_users_sortable_columns filter, so let’s take advantage of this feature to sort users by registration date.
This would be the final result:
You can see that this allows you to have sorted users by registration date.
Here’s how to do it.
Sort WordPress users by creation date
1. Insert a sortable column with the registration date on the users page
Add the following code at the end of functions.php or in your functionality plugin:
The above code comprises several steps:
- Adds a new column to users: registration_date.
- Adds the data for each user to the new column.
- Make the column sortable.
To get the registration date of the users you use the function
get_the_author_meta to extract the metakey named
You can change the text (Registration date) displayed in the column by modifying the line
$columns['registration_date'] = 'Registration date';.
2. Sorts WordPress users by registration date
Once you’ve added the above snippet, when you go to the users page you can see a new column called ‘Registration Date’ (or whatever you’ve decided) being displayed.
The blue color indicates that it is a sortable column, so when you click on it it will sort in ascending order and if you click on it again it will sort in descending order.
You can now see which subscribers have been with you the longest. 😉
Do you want to be able to sort your users by registration date on the general users page?
Now you know how to do it.
If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.
Benefits of being a subscriber. 🙂