Falcon1986-Online

Home of a med student who likes to manage websites and talk tech!

Add/remove contact info fields in WordPress user profiles

with 2 comments

WordPress LogoNot many subscribers to WordPress blogs take the time to fill out contact information on their profile pages. Perhaps a reason for this is that the area is not well promoted, but it could also be that the contact fields are not relevant to some people. The default profile page for WordPress users include input fields for AIM, YIM and Jabber, among others, but wouldn’t it be great if you could add other fields to the set or remove a few of the existing ones? Quite a few people use Facebook and Twitter; why not add fields so they can link to their presence on these social networks? In this post, I will show you how it can easily be done by editing your theme’s functions.php file.

Locate your theme’s functions.php file and open it in a simple text editor. Append with the following lines of code and modify depending on which fields you want to add or remove. Save and visit your profile to test.

// Add extra contact info to user profile page
function extra_contact_info($contactmethods) {
    unset($contactmethods['aim']);
    unset($contactmethods['yim']);
    unset($contactmethods['jabber']);
    $contactmethods['facebook'] = 'Facebook';
    $contactmethods['twitter'] = 'Twitter';
    $contactmethods['linkedin'] = 'LinkedIn';

    return $contactmethods;
}
add_filter('user_contactmethods', 'extra_contact_info');

The code is pretty simple to understand. Fields that you want to remove are preceded with unset; those that you want to add are not.

About these ads

Written by falcon1986

9 March, 2011 at 11:24 AM

Posted in Wordpress

Tagged with

2 Responses

Subscribe to comments with RSS.

  1. thank you for this! there is only one more thing. You have to add the line of code to the autor-info.php of the theme so the template can show the facebook or linkedin links. Anyways, thanks for this helpful info.

    Zona de Arte

    11 March, 2011 at 9:11 PM

    • Yes, the other step would be modifying the relevant page template to display this information. But I will leave that for another post.

      falcon1986

      28 April, 2011 at 10:15 AM


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: