Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Display Recently Registered Users in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Display Recently Registered Users in WordPress

For multi-user WordPress sites, you may want to showcase your users on different sections of your website. For example, you can display a list of authors with avatars, or add an author info box, etc. In this tutorial we will show you how to display recently registered users in WordPress. These users do not need to be authors. It can be used for a community site that allows for user registration.

First thing you need to do is copy and paste the following code in your theme’s functions.php file or in a site-specific plugin.

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 the users on your site by using the following template tag in your theme’s template file such as sidebar.php, footer.php etc:

<?php wpb_recently_registered_users(); ?>

If you want to display newly registered users on a specific page without creating a page template, then you can use a shortcode.

Simply add this code in your theme’s functions.php file or the site-specific plugin, just below the code you entered earlier.

add_shortcode('wpb_newusers', 'wpb_recently_registered_users');

This code will create a new shortcode for you to use in your posts, pages, or widgets. Use it like this:


We hope this article helped you display recently registered users in WordPress. For feedback and questions, please leave a comment.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Jonas says:

    How can display registered users when they are logged in?

    For example…….”Who are online”.

  2. Edmond says:

    So, how can i make it display like horizontally?

  3. Adam says:


    Is there a possibility to display only users with specified roles?

    I’d be really greatfull if you help me on that.

  4. dimmka says:

    Thanks for tutorial.
    How to display quantity recently registered users in wordPress?

  5. Edosa Uyi says:

    Hello Editorial Staff, this post really helped me a lot. Please I want to display the date of registration along with each username,how can I do this?

  6. andrewmichaelsa says:

    Great post, managed to get it working easily. I would now like to style the list any ideas on how that is done?

  7. Ben says:

    I am wondering how to insert a space in between the avatar and the name. Also would like to know how to use the “username” of a buddypress username instead of registered name.

  8. laura says:

    Thank you. I really did not want to “wade in” to the level of just using plug ins for everything I do. However, I want to create a list that no plug in exists to create for me. So, I’ll try to “do it myself”. This helped because I see the basics of “how to do it”. Then, I just have to be more specific in what I do to try to make it put the fields in order that I want listed. LOL ~~ Let’s see how this works! (I will make sure to do backups before trying anything… and I am using a child theme also.) Thanks!

  9. mark taylor says:

    This is very good, how do i stop it showing admin username? Is there some code that can be added to stop admin from being shown, only blog subscribers.

    • WPBeginner Support says:

      You can modify the SQL query on line 07 like this:

      $usernames = $wpdb->get_results("SELECT user_nicename, user_url, user_email FROM $wpdb->users WHERE user_login != 'admin' ORDER BY ID DESC LIMIT 5");
  10. Chris McCoy says:

    you can also use the wp user query.

    $user_query = new WP_User_Query( array(‘orderby’ => ‘user_registered’) );

  11. Rick Meader says:

    None of my new subscribers (including me, as a test) received their password from WordPress. Is there a setting I need in order to have that done?

    • WPBeginner Support says:

      You might have some email configuration issue. Are you getting any emails from your WordPress site? Like for example when a new user registers on the site or when a comment is awaiting moderation? If you are not, then we would recommend you to try WP Mail SMTP plugin.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.