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

How To Check Whether Someone Blocked You On Instagram

All social media platforms including Instagram do not notify people when they get blocked by a user. But when someone’s post and...

Free Apps Make Money through These Innovative Ways

Have you always wondered why are some apps available to you free of cost? If you want to know how apps make...

How To Completely Remove Google Account From Chrome Browser

Google Chrome when used with your personal Google account lets you keep the data in sync with all your devices. Your YouTube...

How To Know If Your Android Smartphone Is Hacked And How To Fix It!

One of the worst nightmares you can ever witness is realizing that your Android Smartphone Is Hacked. Yes, you're allowed to be...

How to Fix Google Drive Not Downloading Files After Zipping

Google Drive is one of the most convenient and easy-to-use file storage services. It allows us to store or host files online,...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here