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.

Display Recently Registered Users

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.


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.

Leave a Reply