When you have a membership WordPress website or a WooCommerce online store with thousands of customers, you need to analyze the customer information. The registered date of the website user is important data you need to know. However, WordPress’s default user list table doesn’t display the user’s registration date, see the screenshot of the user list table below.
We need to add a column to the header of the list table, to display the users’ registration date.
In this article, we will introduce how to add a registration date column to the header of the user list table by creating a plugin. The target of the plugin is to add a new column named ‘Registration date’ to the right side of the posts column. Let’s dive into the steps.
Steps to Add the Registration Date Column
We will create a simple plugin that does the following:
-
- Add a new “Registered Date” column to the Users table.
- Populate that column with the registration date of each user.
- Make the column sortable so you can sort users based on when they registered.
Step 1: Create the Plugin folder and file
We’ll start by creating a simple WordPress plugin that adds a new column name ‘Registration date’ to the user list table.
-
- Create the Plugin Folder
Create a new folder called user-registration-date on your PC. - Create the Plugin File
In the user-registration-date folder, create a PHP file nameduser-registration-date.php
. This will contain the code for your plugin.
- Create the Plugin Folder
Step 2: Add the below Plugin Code to user-registration-date.php
user_registered;
// Format the date or display as is
$value = date_i18n('Y/m/d', strtotime($registered));
}
return $value;
}
add_filter('manage_users_custom_column', 'urd_show_user_register_column', 10, 3);
// 3. Make the "Registered Date" column sortable
function urd_user_register_column_sortable($columns) {
$columns['user_registered'] = 'user_registered';
return $columns;
}
add_filter('manage_users_sortable_columns', 'urd_user_register_column_sortable');
// 4. Ensure the sorting works when clicking the "Registered Date" column header
function urd_user_register_column_orderby($query) {
if (!is_admin()) {
return;
}
$orderby = $query->get('orderby');
if ('user_registered' == $orderby) {
$query->set('orderby', 'registered');
}
}
add_action('pre_get_users', 'urd_user_register_column_orderby');
Step 3. Save and Activate the Plugin
- Save the file and zip the
user-registration-date
folder. - Go to your WordPress dashboard, then navigate to Plugins > Add New.
- Click the Upload Plugin button and upload the zipped folder.
- Once uploaded, click Activate to enable the plugin.
Step 4: Test The Plugin
After activating the plugin, go to your WordPress dashboard:
- Navigate to Users > All Users.
- You will now see a new column labeled Registered Date next to other user information.
- The column will display the registration date of each user in the format
YYYY/MM/DD
. - You can click the Registered Date column header to sort the users by the date they registered.
Conclusion
By adding a custom plugin like this, you can easily track when users registered on your WordPress site directly from the dashboard. This can be useful for membership sites, subscription-based platforms, or any WordPress site that manages user accounts.