WordPress – alphabetical userlist with author_meta entries

For a multi-user blog I decided to realize a kind of member list of all users – not only post authors. (Maybe some of the registered users will never write a post. But all members of the staff are pooled together as users on this blog.)
The meta-fields in the user profiles seemed to be a good idea to , but it was a bit tricky to manage this. The suggestions given in the forums turned out not to be practical and I preferred a solution without a plugin.

So, here is what I figured out:

Every user fills in some information into the profile, where some fields are converted to new data contents. The Jabber-field for example is now used to contain the phone-number.
Additionately the userphoto-plugin is in use to provide an easily accessible user photo for posts, that is only used on this site. Accessing profiles from Facebook was not my intention.
Decisive for being displayed in the user list is the ‚description‘ field in the profile. If there’s no content, the user will not be displayed in the user list. (This facility ought to be offered.)
All other informations are only displayed, if the field has any entry – if there is none, it’s left out.
The entry in the field ‚website‘ determines, if there’s a contact link to e-mail the user.

So, here’s the code implemented in it’s own ‚user-list-template‘-file:

<h1 class='pagetitle'>Users:</h1>
<small>(alphabetical order)</small>
<hr>
<?php
$authors= $wpdb->get_results('SELECT ID, user_nicename from wp_users ORDER BY user_nicename');
if($authors):
foreach($authors as $author):
?>
<div class='author' id='author-<?php the_author_meta('user_login', $author->user_id); ?>'>
     <?php if(get_the_author_meta('description', $author->ID)): ?> 
<div class='description'>
<div class='alignleft'>
	 
</div>
	<big><?php the_author_meta('first_name', $author->ID); ?> <?php the_author_meta('last_name', $author->ID); ?></big><br>
	<?php if(get_the_author_meta('yim', $author->ID)): ?>Data A: <?php the_author_meta('yim', $author->ID); ?><br><?php endif; ?>
	<?php if(get_the_author_meta('aim', $author->ID)): ?>Data B: <?php the_author_meta('aim', $author->ID); ?><br><?php endif; ?>
	<?php if(get_the_author_meta('jabber', $author->ID)): ?>Phone: <?php the_author_meta('jabber', $author->ID); ?><br><?php endif; ?>Data C: <?php the_author_meta('description', $author->ID); ?><br>
	<?php if(get_the_author_meta('user_url', $author->ID)): ?><?php endif; ?> 
<hr>
</div>
<?php endif; ?>
</div>
<?php endforeach; endif; ?>

I hope it fits your needs and you enjoy.

You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.

Comments are closed.