For one of our clients, we needed to list all the users on the site, first by role, and then within that role, alphabetized by last name. Each user needed to display the author’s name (First Name, Last Name), the author’s photo (using the User Photo plugin), and some author meta information, as follows:

Editors:

Stan Smith (links to Author’s archive using the author.php archive)
Bio/Description
Email
Website

John Tmith (links to Author’s archive using the author.php archive)
Bio/Description
Email
Website

Abe Zmith  (links to Author’s archive using the author.php archive)
Bio/Description
Email
Website

Authors:

Mary Smith (links to Author’s archive using the author.php archive)
Bio/Description
Email
Website

Ann Tmith (links to Author’s archive using the author.php archive)
Bio/Description
Email
Website

Sarah Zmith  (links to Author’s archive using the author.php archive)
Bio/Description
Email
Website

Here’s the code we used to accomplish this.

Step 1: In functions.php, add the following code:  

[cc lang=”PHP”]function illuminea_list_users() {
$blogusers = get_users( ‘blog_id=1&orderby=nicename&role=author’ );
$editors = get_users( ‘blog_id=1&orderby=nicename&role=editor’ );

foreach( $editors as $user ) {
?>

userphoto($user);
?>
echo ‘

‘ . $user->display_name . ‘

‘;
echo ‘

‘ . $user->description . ‘

‘;
echo ‘

‘;
if($user->user_url) {
echo ‘

‘;
}
?>

}

foreach ($blogusers as $user) {
if ( ‘author’ != array_pop($user->roles) )
continue;
?>

userphoto($user);
?>
echo ‘

‘ . $user->display_name . ‘

‘;
echo ‘

‘ . $user->description . ‘

‘;
echo ‘

‘;
if($user->user_url) {
echo ‘

‘;
}
?>

}
}
[/cc]

Step 2: In the Researchers.php Page Template, add the following code:

[cc lang=”PHP”]
/*
Template Name: Researchers Template
*/
get_header();

function illuminea_modify_user_query( $q ) {
global $wpdb;
remove_action( ‘pre_user_query’, ‘illuminea_modify_user_query’ );

$q->query_orderby = “ORDER BY $wpdb->usermeta.meta_value ASC”;
$q->query_where = “WHERE 1=1 AND $wpdb->usermeta.meta_key = ‘last_name'”;
}
add_action( ‘pre_user_query’, ‘illuminea_modify_user_query’ );
?>

[/cc]