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>";

endif;
}
$recentusers .= '</ul>';

return $recentusers;  
}

your theme’s template file such as sidebar.php, footer.php

<?php wpb_recently_registered_users(); ?>

or you can use short code

add_shortcode('wpb_newusers', 'wpb_recently_registered_users');

like this:

[wpb_newusers]

Advertisements