How to Randomly Display Registered Users in WordPress

Your customers are the superstars of your multi-user WordPress web site. There are some ways you’ll spotlight customers and authors in your web site. Previously we confirmed you ways to upload an creator information field, and the way to show lately registered customers. In this newsletter, we can display you ways to show a random record of registered customers in WordPress.

First factor you want to do is replica and paste the next code in your theme’s purposes.php document or in a site-specific plugin.

serve as wpb_random_users() { 

world $wpdb;

$randomusers="<ul elegance="random-users">";

// Query database for customers
$usernames = $wpdb->get_results("SELECT user_nicename, user_url, user_email FROM $wpdb->customers ORDER BY RAND() LIMIT 5");

// Display customers in an inventory
foreach ($usernames as $username) {

if (!$username->user_url) :

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

else :

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

$randomusers .= '</ul>';

go back $randomusers;  


This code queries the WordPress customers desk in your database and selects a random row, then it outputs the effects in a bulleted record with consumer’s avatar and identify. If a consumer has equipped the site URL in their profile, then it’ll hyperlink the consumer identify to their site.

Next factor you want to do is show the record of registered customers. To do that, all you want to do is upload the next line of code in your theme document the place you need the consumer record to be displayed (reminiscent of sidebar.php, footer.php and many others).

<?php wpb_random_users(); ?> 

You too can show an inventory of random customers out of your web site the usage of this shortcode in a submit, web page, or a widget.


We hope this newsletter helped you show a random record of registered customers in your WordPress web site. If you had been having a look to show an inventory of your body of workers individuals, then you definately will have to take a look at this instructional on how to create a body of workers record in WordPress.

If you’ve any questions or comments, then please depart us a remark underneath. Also don’t fail to remember to apply us on Twitter and sign up for us on Google+

Recent Articles

Fix-iPhone Hotspot Not Working

Network related issues are the common problems that we all encounter while using a smartphone. Are you facing a problem using your...

Snapchat streak Made Easy for Beginners with the Best Tips

Snapchat streak won’t help you with all your life problems, but will surely give you a strange sense of accomplishment. Unlike streaks...

Facebook Messenger Alternatives that Keep Your Chat Private

Facebook might be the king of social media ever since its launch 16 years ago, but it is not entirely safe. If...

How to use iOS 14’s new Headphone Audio Customization feature

Apple’s iOS14 comes with several new features. Among them, the most useful feature is it allows to customize iPhone headphone for a...

How to limit third party access to Photos app in iPhone – iOS 14

The new iOS 14 has introduced several new features related to security and privacy. If you are more concerned about your privacy then...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here