Display user registration date in wordress116

User Register

It is always better to know something about your users than you know nothing about them. Knowing the registration date of your users will help you make several decisions regarding your site. Getting the registration date of users can also help you take several decisions. So, if you are willing to show user registration date in WordPress, you may read the article further:

Only Viewable for admin:

If you want only admin to view the registration date of users, you may follow the steps below:

  1. Go to Settings > Admin Columns. Demo picture is shown below:
  2. Click on Add Column, select ‘Registered’ in Type drop down and click on ‘store updates’ button.
  3. Now you will be able to see Registered date of all users. Demo picture is shown below:

    User Date

 

Showing registration date in User Profile

In order to show registration date in user’s profile. You need to create a custom plugin. Here are the steps you need to follow ahead:

  1. Open notepad and copy the paste below:
/*
Plugin Name: Member Since
Plugin URI:  http://www.infobeep.info
Description: Adds registration date on edit user profile screen. 
Version:     1.0
Author:      IB Group
*/
 
 
namespaceShowMemberSince;
add_action( 'plugins_loaded', 'ShowMemberSince\init');
/**
 * Adding needed action hooks
*/
functioninit(){
  foreach( array( 'show_user_profile', 'edit_user_profile') as $hook)
        add_action( $hook, 'ShowMemberSince\add_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) )
    );
}

  1. After copied, save the file as membersince.php on your desktop
  2. Now, go to your website /wp-content/plugins/folder. Select membersince.php file and upload here.
  3. Lastly, go to WordPress plugin page and activate this plugin.

 

Showing User registration date on website

This is a simple way to show user registration date on website. You just need to paste the code below in your theme’s function.php file:

function ib_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', 'ib_user_registration_date');

note: now you can display user registration date by simply using short code like:

[membersince user=peter]

Photo Credit : https://www.jisc.ac.uk