How to Add and Delete Contact Info Fields for Your Users

How I changed the contact info area of my user profile page
Updated Profile Page with New fields

I want to share a code snippet I recently learned about from following the action (online) at WordCamp Montreal. This is a function written by Stephanie Leary and was presented in her slideshow available here. This function allows you to add/remove/edit the available fields in the Contact Info area of a WordPress user’s Profile page.

Why would you want to do this? Let’s have a look at the default Contact Info area of the Profile page.

How to edit the user profile page in WordPress
Contact Info of Profile Page

Ok, the first two  fields above are useful for sure, but the others? They may be useful to some WordPress site administrators but I’m guessing that number is small in relation to the millions of WordPress installations worldwide. That’s only a guess and I can only speak for myself…and I have no use for knowing any of my user’s AIM account details. So, I want to get rid of that field.

Now that we’re editing this function code, we might as well add some more fields too. This would be information a bit more specific to your WordPress site’s purpose. For my needs, I wanted to add Company Name, Title, Phone Number, and Twitter fields.

Here’s the exact function code I’m using:

function change_contactmethod( $contactmethods ) {
//Add some fields
$contactmethods['company'] = 'Company Name';
$contactmethods['title'] = 'Title';
$contactmethods['phone'] = 'Phone Number';
$contactmethods['twitter'] = 'Twitter Name (no @)';

//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);

I placed this function in the functions.php file that exists inside the theme folder for the theme I have activated on my site. I saved my changes, refreshed the Profile page and got the desired result as seen below.

How I changed the contact info area of my user profile page
Updated Profile Page with New fields

Keep in mind that this is really only an initial step in how you can make better use of your user Profile pages. What would you do?

[box color=green]Has this tutorial been helpful? Why not sign up for email updates here and share this page on your preferred social network below? You might also want to become a Free Member over at AdamWWarner.com and learn even more WordPress website techniques.[/box]

[AppAd]