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… Read More »

The post How to Show User Registration Date in WordPress appeared first on WPBeginner.

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.

Showing a the date of a user's registration 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.

Add registered column in users table

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.

Users table with registration date column

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:  http://www.wpbeginner.com
Description: Adds registration date on edit user profile screen. 
Version:     1.0
Author:      WPBeginner
*/


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 member registration date in WordPress user profile

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.

The post How to Show User Registration Date in WordPress appeared first on WPBeginner.