How to Use Wordpress as a Membership Directory

UPDATE: This is a repost of a guest post I made earlier this year over at WPDesigner. I am reposting it here because of the neglect that has taken place recently over at WPDesigner. I will only be responding to questions on this article from now on. Thank you for your understanding. (FYI: My WPDesigner guest post was an unpaid one, so I am in no way stealing from anyone here…)
This article was written by Chris Cagle.
Do you want to create a moderated membership directory that showcases your member's information? Do you want it to be flexible, be very little work after initial setup, and use a world-class open source platform that you are already familiar with?
Your first thought might not be to use Wordpress for such a project, but since it already has an extremely easy way to accept, moderate and update registrations - it's a perfect candidate.
In this tutorial I will show you how I built a successful membership directory using nothing more than a standard Wordpress 2.3+ install and 2 very powerful plugins.
The Plugin Installs
The heart of the site is powered by two plugins.
First, use the WP User Manager plugin from Dealsway to add new fields to the user profiles. The install and setup is pretty straight forward - just activate the plugin and add any new fields you want via it’s own admin section. The information entered in these fields will become the information that will create the member's "homepage."
Secondly, we use the famous Role Manager plugin which restricts what your members can do once they are logged into your site. This is important because in order for a member to be granted their own author page, he or she needs to have made at least one post.
In my case, I didn't want my members to have the ability to post anything, just to only fill out their profile information. To get around this, I used the Role Manager plugin as-is, but changed the Author role to only have the rights Publish Posts and Read. (The Hide Dashboard capability you see in the screen shot is a function of the IWG Hide Dashboard plugin. It was an easy way to clean up the admin panel for my members.)

Setting Wordpress Options
After you have installed all the plugins, we need to get Wordpress ready for your new registrations.
In your Admin panel, under options, set your New User Default Role to Subscriber. This ensures that a member won't be given an author page until you "approve" and manually move them to the Author role. (A Subscriber can't make posts, an Author can.)

Once a member has registered and filled out all the appropriate profile information, we need to "approve" that member. We do this by simply moving that member into the Author role and making a post on his or her behalf. I want each approved member to have made a post in order to create the New Member Feed [example]. To post on behalf of that member, choose that member's name out of the dropdown list in the Post Author section in the sidebar before publishing their post.

This post doesn't need to be anything spectacular. On Pittsburgh Designers, I simply write "This business has been added as a member. Please visit their Design Profile."
There are other ways of doing this to make it slightly simpler, but I do it this way because I want to use Wordpress's default feed as a New Member Feed.
Your membership management duties are now done.
Creating the Author Page
All that's left now is the need to create the author.php template to display all this new member profile information that the WP User Manager plugin allowed us to accept.
For the sake of this tutorial, we only added 2 new fields to the member profile page: business_name and business_owner.
At the top of the author.php template we will add this code. Hint: Each new field you add will need to be declared here.
<?php
/*
Template Name: Author Template
*/
global $wp_query;
$curauth = $wp_query->get_queried_object();
$key="wpum_"."business_name";
$business_name = get_usermeta($curauth->ID, $key);
$key="wpum_"."business_owner";
$business_owner = get_usermeta($curauth->ID, $key);
?>
Now right below that, in the body section of your template, we are going to add this data and markup to display it in a structured way:
<?php get_header(); ?>
<div id="bodycontent" >
<div class="bodytext" >
<h2><?php echo $business_name; ?></h2>
<p>The owner of this business is <?php echo $business_owner; ?></p>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
The next step is to also show some of the default fields that the member entered within their profile. I only want to show the member's website address and About the user section, so we modify our template to look like this:
<?php get_header(); ?>
<div id="bodycontent" >
<div class="bodytext" >
<h2><?php echo $business_name; ?></h2>
<p>The owner of this business is <?php echo $business_owner; ?></p>
<p>Website: <a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url;?></a></p>
<p>About the Business: <?php echo $curauth->description; ?></p>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Hint: A full list of $curauth-> calls can be viewed in the Wordpress Codex.
Lastly, we want to do some basic error checking.
What would happen if the member didn't put anything in the business_owner field? In this case, we can just wrap that line in an if statement (…or any variable we want to protect against being blank):
<?php if ($business_owner != null) { echo "<p>The owner of this business is
".$business_owner."</p>"; }; ?>
Listing your Members
So how do you list all of your approved members? It is as simple as adding the wp_list_authors to any template file. This is the customized version of that function I use:
<?php wp_list_authors(’hide_empty=1&show_fullname=0&optioncount=0&exclude_admin=0');
?>
Tutorial Wrapup
This tutorial was based on my experiences in building the Pittsburgh Designers community into a thriving, local membership directory for creative types. Mosey on over to the site and take a peek for yourself how what a finished project like this can look like.
You can download the complete finished author.php template here.
About the Author
Chris Cagle is a freelance web designer from Pittsburgh, PA, whose projects include Pittsburgh Designers and AdClustr.

April 24th, 2008
9:56 pm
Good luck with this Chris, I'm looking forward to seeing your 2.5 update - I've been reading up on the three plugins and, despite one or two reported glitches, they all seem to be basically okay under the current WordPress.
My ultimate goal is to find a way for new members to create a post upon registration that gets put into the moderation queue; your example of how to slot the contents of custom fields into a template has given me hope that it might be possible - thanks for the inspiration.
May 6th, 2008
3:32 pm
Hello there … this reads very well and reminded me of what the guys at buddypress are doing !!! . Above however seems to be a simpler way and wondered if you or anyone out there has a link to a site that is essentially what you've explained above !!!
Keep at it !!
May 6th, 2008
3:34 pm
other than the one above of course !!!
Administrator
May 6th, 2008
5:15 pm
Hey Graham - thanks for stopping by!
I haven't been notified of anyone using an implemented version of the above (probably as WordSkill above points out that my tut was for WP 2.3). But saying that, I am not really sure that WP 2.5 should any issues with this.
I would really love to see some directories using this as well….
May 7th, 2008
4:32 am
I would like to set-up our blog exactly like this to allow our readers to set-up profiles. The problem with this method is that I would have to accept every member and make them a page too. Not bad if you have a few members a day. But if you hope to get thousands of users then it becomes less practical. Could you think of a 'one click' solution where you approve someone and they automatically get their profile page?
Administrator
May 7th, 2008
6:34 am
@Boris - I looked at this, but I couldn't find a way to automatically generate a post from someone just by them registering, or otherwise. Of course, i only have a small membership (currently at ~106) so it wasn't that big of an issue for me.
But then again, I think a system with thousands of members, maybe should be using a better equiped system than Wordpress. Maybe you can use a third party app to do this, and modify Wordpress to recognize their profiles on that app instead of the default WP one… just a thought…