This is the beginning of a three-part series on building a user directory.
Part 1: Changing the contact fields on the user profile pages
Part 2: Building the user directory page template
Part 3: Building author templates and linking them in the directory
First, we’ll add some new fields: Twitter username, phone number, and job title. Then, we’ll remove the built-in fields we don’t want (all the IM handles). Finally, we add the filter that makes it all work. Here’s the code:
// change user contact fields function change_contactmethod( $contactmethods ) { // Add some fields $contactmethods['twitter'] = 'Twitter Name (no @)'; $contactmethods['phone'] = 'Phone Number'; $contactmethods['title'] = 'Title'; // Remove AIM, Yahoo IM, Google Talk/Jabber unset($contactmethods['aim']); unset($contactmethods['yim']); unset($contactmethods['jabber']); // make it go! return $contactmethods; } add_filter('user_contactmethods','change_contactmethod',10,1);
Put that in your theme’s functions.php
file and have your users fill in the new fields! In the [link id=”2715″]next installment[/link], we’ll build the page template that displays the information.
Leave a Reply