You're here: Home » WordPress » Add Contact Fields to User Profile

Add Contact Fields to User Profile

On Aug 27, 2011 under WordPress

In WordPress, the default user profile page has only few contact field details such as AIM, Yahoo IM, Jabber, Google Talk and E-mail. Though there are quite a few it is definitely not complete without having the mighty Twitter, LinkedIn, Facebook and Google Profile. Here comes a simple piece of code to add those extra fields. You can extend this code and make many more contact fields.

Paste the below code in your theme’s functions.php file. Save changes.

function extra_contact_info($contactmethods) {
    $contactmethods['facebook'] = 'Facebook';
    $contactmethods['twitter'] = 'Twitter';
    $contactmethods['linkedin'] = 'LinkedIn';
    $contactmethods['gprofile'] = 'Google Plus Profile';
    return $contactmethods;
}
add_filter('user_contactmethods', 'extra_contact_info');

Hold on. One more tip is there. If you want to remove some contact fields such as Yahoo and AIM, then you can modify the code as shown below.

function extra_contact_info($contactmethods) {
    unset($contactmethods['aim']);
    unset($contactmethods['yim']);
    $contactmethods['facebook'] = 'Facebook';
    $contactmethods['twitter'] = 'Twitter';
    $contactmethods['linkedin'] = 'LinkedIn';
    $contactmethods['gprofile'] = 'Google Plus Profile';
    return $contactmethods;
}
add_filter('user_contactmethods', 'extra_contact_info');

The second and third lines starting with unset… does the removal work.

Comments on this entry (5 comments)

Did you like this post? You can share your opinion with us! Simply click here.

  1. trouble says:

    wow, thank for tip.

  2. NS MUKUNDAN says:

    I have added several contact fields to the profile of guest authors. It’s very handy and useful. A much needed snippet.
    NS MUKUNDAN recently posted..Herbal Treatment for Toothache

Leave a Reply

CommentLuv badge