How to display recently registered users in WordPress?

girls_making_self_portrait

Whether you run your own blog or manage the company’s website, it is always good to display more information about new users of your website. Fortunately, WordPress provides us with lots of possibilities to customize displaying this information to our own, specified needs. Let us get started!

ENCODING

First thing that has to be done to enter above mentioned option is typing down this formulas into your 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>”;
  • endif;
  • }
  • $recentusers .= ‘</ul>’;
  • return $recentusers;
  • }

 

Actually, most of the job is already done and it would not be the worst moment to stop – you already provide info about your recently registered users. However, would be advisable to show those users on your website. We may do it by adding this command to functions.php file:

  • <?php wpb_recently_registered_users(); ?>

This is mostly everything, there might be of course much more experimenting, which we strongly advise you to, however this is all you need to display your recently registered users onto your website :)