How to Show User Registration Date in WordPress

Do you want to show the user registration date in WordPress? Often popular membership sites and forums display the user registration date on profile as β€œmember since 2015”. In this article, we will cover how to show user registration date in WordPress.

Where and How You Want to Show User Registration Date?

Some of you may just want to display a user’s registration date in the admin columns of the Users page. This will give you a quick overview of when a user joined your website and allow you to sort by registration date.

Another usage scenario is to display a user’s registration date on the β€˜Edit Profile’ page. This will allow any administrator and the user themselves to see when they joined your website.

Last but probably the most popular usage scenario is when you want to display the user registration date on their public profile on the front-end of your website.

Let’s take a look at how you can do all of them.

Adding Registered Date Column on Users Page in Admin Area

First thing you need to do is install and activate theΒ Admin ColumnsΒ plugin. Upon activation, you need to visitΒ Settings Β» Admin ColumnsΒ to configure the plugin.

Under the admin columns tab, click on users and then click on add column button.

Next select β€˜Registered” in the Type drop down menu and click on store updates button.

You can now visit the users screen where you will see a new column labeled β€˜Registered’ showing the date when a user registered on your WordPress site.

See what other things you can do toΒ add and customize admin columns in WordPress.

Showing Registration Date Field in User Profile

For showing registration date on the edit profile page, you will need to upload a custom plugin to your website.

Simply create a new file on your computer using a text editor like Notepad and save it as membersince.phpΒ on your desktop.

Next open the file and paste the following code inside it.

<?php
/*
Plugin Name: Member Since
Plugin URI:Β  https://www.pluginthemehub.com
Description: Adds registration date on edit user profile screen.
Version:Β  Β  Β 1.0
Author:Β  Β  Β  Pluginthemehub
*/
namespace ShowMemberSince;
add_action( ‘plugins_loaded’, ‘ShowMemberSinceinit’ );
/**
Β * Adding needed action hooks
*/
function init(){
Β  foreach( array( ‘show_user_profile’, ‘edit_user_profile’ ) as $hook )
Β  Β  Β  Β  add_action( $hook, ‘ShowMemberSinceadd_custom_user_profile_fields’, 10, 1 );
}
/**
Β * Output table
Β * @param object $user User object
Β */
function add_custom_user_profile_fields( $user ){
Β  Β  $table =
Β  Β  ‘<h3>%1$s</h3>
Β  Β  <table class=”form-table”>
Β  Β  Β  Β  <tr>
Β  Β  Β  Β  Β  Β  <th>
Β  Β  Β  Β  Β  Β  Β  Β  %1$s
Β  Β  Β  Β  Β  Β  </th>
Β  Β  Β  Β  Β  Β  <td>
Β  Β  Β  Β  Β  Β  Β  Β  <p>Member since: %2$s</p>
Β  Β  Β  Β  Β  Β  </td>
Β  Β  Β  Β  </tr>
Β  Β  </table>’;
Β  Β  $udata = get_userdata( $user->ID );
Β  Β  $registered = $udata->user_registered;
Β  Β  printf(
Β  Β  Β  Β  $table,
Β  Β  Β  Β  ‘Registered’,
Β  Β  Β  Β  date( “M Y”, strtotime( $registered ) )
Β  Β  );
}
?>

Save your file and then upload it to your WordPress site.

Finally you can connect to your WordPress site using a FTP client and then go to /wp-content/plugins/Β folder. Select the membersince.php file from your computer and then upload it.

Now you can go to your WordPress plugins page and activate this plugin on your website.

That’s all. Verify everything is working by editing a user profile on in your WordPress admin area, and you will see the user registration date.

Showing User Registration Date on Your Website

In this method, we will be using a simple shortcode to display any users registration date on the front-end of your WordPress site.

First you will need to add the following code in your theme’sΒ functions.phpΒ file or in aΒ site-specific plugin.

function wpb_user_registration_date($atts, $content = null ) {
$userlogin = shortcode_atts( array(
‘user’ => FALSE,
), $atts );
$uname = $userlogin[‘user’];Β  Β Β 
if ($uname!== FALSE) {Β  Β  Β  Β  Β  Β Β 
$user = get_user_by( ‘login’, $uname );Β 
if ($user == false) {
$message =’Sorry no such user found.’;
} else {
$udata = get_userdata( $user-ID );
$registered = $udata->user_registered;
$message =Β  ‘Member since: ‘ . date( “d F Y”, strtotime( $registered ) );
}
Β  Β  Β 
} else
{
$message = ‘Please provide a username.’;
Β 
}
Β 
return $message;
Β 
}
Β 
add_shortcode(‘membersince’, ‘wpb_user_registration_date’);

Next, you can display a user’s registration date by simply using theΒ shortcodeΒ like this:

[membersince user=peter]

Replace peter with the username that you want to show.

We hope this article helped you show registration date in WordPress user profiles. You may also want to see our tutorial on how toΒ add additional user profile fields in WordPress registration.

If you liked this article, then please subscribe to ourΒ YouTube ChannelΒ for WordPress video tutorials. You can also find us onΒ TwitterΒ andΒ Facebook.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!

Pin It on Pinterest

Add address