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 :

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

//GETTING INFO FROM EACH USERS
//get the user's email ID
$email = $user->user_email;

//build the gravatar URL
$grav_url = "http://www.gravatar.com/avatar.php?
gravatar_id=".md5( strtolower($email) ).
"&default=".urlencode($default).
"&size=".$size;

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

//get the user's URI
$user_url=$user->user_url;

//get the user's nickname
$user_nickname=$user->nickname;

//get the user's description ( the biographical info field, )
$user_profile=$user->description;

?>






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

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

2018 All rights reserved | Powered by WordPress
Back to top
Theme by dynamicguru.com