Add/remove contact info fields

User profiles in WordPress have these fields for Contact Info by default: E-mail, Website, AIM, Yahoo IM, Jabber / Google Talk. You can remove those and add new ones as you wish, like in this example code for your functions.php file in your theme:

function new_contactmethods( $contactmethods ) {
   $contactmethods['twitter'] = 'Twitter'; // Add Twitter
   $contactmethods['facebook'] = 'Facebook'; // Add Facebook
   unset($contactmethods['yim']); // Remove YIM
   unset($contactmethods['aim']); // Remove AIM
   unset($contactmethods['jabber']); // Remove Jabber

   return $contactmethods;

To display that publicly, you could:

$user_id = 1;
$key = 'twitter';
$single = true;

$user_twitter = get_user_meta( $user_id, $key, $single); 

echo $user_twitter; 

Reference URL


  1. Hassan
    Permalink to comment#

    Missed a line! Without defining the filter, the function itself won’t do anything!

  2. Matt Royce
    Permalink to comment#

    Really like this, and glad I’ve found it! Definitely going to use it on my WordPress installs.

  3. Methemer
    Permalink to comment#

    Awesome. Didn’t know this, thank you.

  4. OneWorld
    Permalink to comment#

    Removing just works for those three: AIM, YIM, Jabber ;(

  5. Alexandre
    Permalink to comment#

    unset ($ contactmethods [‘url’]) does not remove

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences like this:

  function example() {
    element.innerHTML = "<div>code</div>";

We have a pretty good* newsletter.