Skip to content

How To Display Recently Registered Users In WordPress

For multi-user WordPress, you may want to show your recently registered users on your website to attract more people to register for an account on your website. We have to ways and codes to do this job, and here they are:

First Code

This code comes from WPBeginner. Just paste following code to your current theme’s functions.php file:

function wpb_recently_registered_users() { 

global $wpdb;

$recentusers = '<ul class="recently-user">';

$usernames = $wpdb->get_results("SELECT user_nicename, user_url, user_email FROM $wpdb->users ORDER BY ID DESC LIMIT 5");

foreach ($usernames as $username) {

if (!$username->user_url) :

$recentusers .= '<li>' .get_avatar($username->user_email, 45) .$username->user_nicename."</a></li>";

else :

$recentusers .= '<li>' .get_avatar($username->user_email, 45).'<a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>";

$recentusers .= '</ul>';

return $recentusers;  

Now, you can display recently registered users on your site by using the following template tag in your theme’s template file such as sidebar.php file:

<?php wpb_recently_registered_users(); ?>

Second Code

The second code for doing showing recently registered users comes from <emoticode/>. Just add following code to your theme where you want to display recently registered user:

<ul class="recently-user">
    <?php $usernames = $wpdb->get_results("SELECT user_nicename, user_url FROM $wpdb->users ORDER BY ID DESC LIMIT 5");
        foreach ($usernames as $username) {
                echo '<li>' .get_avatar($username->comment_author_email, 45).'<a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>";

Leave a Reply

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