How to list all registered users on your wordpress site

In my latest project i was required to add a community touch to a site by listing the Name, Email, Nickname, URI and Gravatar of all the registered users on the site. I came with the following solution : I made a new page template called users and added the following lines of php to the template :

	First we set how we'll want to sort the user list.
	* ID - User ID number.
	* user_login - User Login name.
	* user_nicename - User Nice name ( nice version of login name ).
	* user_email - User Email Address.
	* user_url - User Website URL.
	* user_registered - User Registration date.

$sort= "user_registered";

//the default avatar to display in case gravatar is not available for a user
$default = "";

//the size of the gravatar , here 96px
$size = 96;

//Build the custom database query to fetch all user IDs
$all_users_id = $wpdb->get_col( $wpdb->prepare(
	"SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC"
	, $sort ));

//we got all the IDs, now loop through them to get individual IDs
foreach ( $all_users_id as $i_users_id ) :

// get user info by calling get_userdata() on each id
$user = get_userdata( $i_users_id );

//get the user's email ID
$email = $user->user_email;

//build the gravatar URL
$grav_url = "
gravatar_id=".md5( strtolower($email) ).

//get the user's full name
$user_fullname=$user->first_name . ' ' . $user->last_name;

//get the user's URI

//get the user's nickname

//get the user's description ( the biographical info field, )


<!-- Now here you can display each users info using the variables defined above -->

endforeach; // end the users loop.

If you are looking for online printing company to hang one you should check out Psprint.

Hope you found it useful, cheers :) , WORDPRESS ROCKS

2019 All rights reserved | Powered by WordPress
Back to top
Theme by