Du musst dich anmelden um Beiträge und Themen zu erstellen. Einloggen · Registrieren

List WordPress User Information

Here is an easy way to display flexible lists of your blog’s registered users’ information. In this example, we will list the first and last name of each user registered in the database:

<?php $szSort = "user_nicename";  
$aUsersID = $wpdb->get_col($wpdb->prepare("SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC", $szSort)); 
	foreach($aUsersID as $iUserID) :
		$user = get_userdata($iUserID);
		echo '<li>'.ucwords(strtolower($user->first_name.' '.$user->last_name)).'</li>'; 

The following variables may be used to display different types of user information and also to specify the sort order of the output list:

  • ID — User ID number
  • user_login — User Login name
  • user_nicename — nice version of login name
  • user_email — User Email Address
  • user_url — User Website URL
  • user_registered — User Registration date

To display any of these different types of user information, call it with $user->name_of_the_columnanywhere within the function’s foreach() loop. To change the display order of the output, use any of the above as the value of the $szSort variable in the first line of the function. Note that strtolower and ucwords are used to ensure proper capitalization of the user names.

Source: Matt Varone (404 link removed 2015/02/26)