Soliloquy - The Best Responsive WordPress Slider Plugin

How to Add Custom User Contact Info in WordPress

Share This Post

If there is one thing that I do not like about WordPress, it is the fact that it gives outdated options for user contact information. AIM? Yahoo? The internet has steadily moved away from these to things like Facebook and Twitter. After some digging around in the core files of WordPress and hunting on the internet, I’ve found a way to add custom user contact information fields in the ‘Users’ section of WordPress through the functions.php file (or custom_functions.php file if you use Thesis).

Let’s get started with our tutorial!

Setting Up the Function

The awesome thing about this tutorial is that we don’t need to mess with any of the core files in order to make this work. All we need to do is write our own function that determines the contact information input fields for our users.

Copy and paste the following code into your functions.php or custom_functions.php file:

[php]/* BEGIN Custom User Contact Info */
function extra_contact_info($contactmethods) {
$contactmethods['facebook'] = ‘Facebook’;
$contactmethods['twitter'] = ‘Twitter’;
$contactmethods['linkedin'] = ‘LinkedIn’;
return $contactmethods;
add_filter(‘user_contactmethods’, ‘extra_contact_info’);
/* END Custom User Contact Info */[/php]

Breaking Down the Code

Basically what is happening here is we are creating a new function called extra_contact_info and applying it as a filter to $user_contactmethods. You can learn more about $user_contactmethods by going to your wp-includes/registration.php file and scrolling to the very bottom to see the code for it.

Within this function we are adding some filters. The first set of filters is applying the unset rule, which essentially destroys (unsets) a previously set variable. What this means for you is that it causes WordPress to remove the default user contact information fields of “AIM”, “Yahoo”, and “Jabber/Google Talk”. If you would like to retain one or more of these fields, simply remove the line that references one of these three things.

The next set of filters creates new user contact information fields for us to use. In this example, I’ve created new fields that can be used for Facebook, Twitter and LinkedIn. All we are telling WordPress to do is register these new input fields for us.

Finally, we use add_filter in order to apply our changes.

How to Add Custom User Contact Info in WordPressSave your file and go to the “Edit” portion of your own user. You will notice that you have awesome new contact information fields that are actually relevant to your users! You can view an example of what it should look like in the image to our left.

Making Use of Our New Contact Fields

Making use of these fields is just as simple as displaying the author’s name, URL and number of posts he/she has made. We just apply a little PHP and bam, our user contact info is in use.

You can call any of these fields by using this PHP command:

[php]<a href="<?php the_author_meta(‘facebook’, $current_author->ID); ?>"></a>[/php]

This creates a link to whatever URL your user entered in the “Facebook” contact field. Simply swap out ‘facebook’ for any other field that you defined in your function (for this example, ‘twitter’ or ‘linkedin’) in order to display that particular URL information.

Customizing your users contact information inputs is especially useful for post author boxes.
Now you have the option of easily setting up Facebook and Twitter links for your guest posts.

Enjoy and let me know if you have any questions on how to get things done!

Have you enjoyed reading How to Add Custom User Contact Info in WordPress? Sign up below to get regular content updates and also get my "7 Tips to a Professional WordPress Setup" absolutely free!

About Thomas Griffin

I live and breathe WordPress. I create products around WordPress (Soliloquy and OptinMonster), contribute to WordPress core and do lots of fun development around WordPress in general. You can find me on Twitter, Facebook and Google+.

38 Responses to “How to Add Custom User Contact Info in WordPress”

  1. You don’t need unset() if you remove all default fields. Just return the new array.
    My approach:

  2. [...] thanks Thomas Griffin for the snippet! If you enjoyed this article, please consider sharing it! tweetmeme_style = [...]

  3. [...] a Thomas Griffin una vez más. Tweet Clasificado en Artículos 019/10/2010 Clic para cancelar [...]

  4. [...] | Translate Sharetweetmeme_source='wphey';tweetmeme_style='compact'; Here is the snippet by Thomas Griffin to help you change user contact info in WordPress. You can use this to remove the AIM and YIM [...]

  5. [...] users would probably enjoy this class which allow you to manage user contact info easily. Source: browser caching via .htaccessOne of the easiest way to improve your blog speed and general [...]

  6. Thao says:

    Great snippet Thomas. Thanks for that. Just used in on our MultiSite install, so it will be uber-handy. No more AIM or Yahoo. And we excluded FaceBook also – just because we hate FaceBook.

  7. Cecile says:

    Hi Thomas and thanks for the great tip ! I’m actually trying to use it on aWP-based social network built with mingle in order to add this “facebook” and “twitter” links to the profile of each member but what happens is strange.

    It retrieves the information entered by the actual member connected on every profile of each member, instead of the specific information entered by the user himself..!

    Is this part’s fault ? the_author_meta or $current_author->ID / $user->ID ?

    • Cecile,

      That’s a peculiar bug for sure! Using the variable $current_author should only take the values from that specific author and not all of them. Can I see your code?


      • Cecile says:

        Sure !
        So, below is a portion of a user’s profile page, where datas are taken from each user’s contact informations as entered on the admin dashboard.

        privacy == 'public' or
        MnglUser::is_logged_in_and_an_admin() or
        MnglUser::is_logged_in_and_visible() ); ?>

        // Display the photo uploaded by the user
        id); ?>

        // This displays the biography, aka the "about the author" text. And it works fine.
        field_visibilities['profile_front']['bio']) and !empty($user->bio)) { ?>
        bio); ?>
        // There I've tried to inject your code to display the link to the facebook URL entered by the user
        <a href="ID); ?>">My facebook profile

        // This displays the name of the user and it works well too !
        field_visibilities['profile_front']['name']) and !empty($user->first_name) and ($user->first_name != $user->screenname)) { ?>
        :first_name)); ?>
        last_name)){ ?>
        last_name)); ?>

  8. [...] Advanced users would probably enjoy this class which allow you to manage user contact info easily. Source: [...]

  9. [...] to Thomas Griffin for the snippets! (function() {var s = document.createElement('SCRIPT'), s1 = [...]

  10. Thanks Thomas. This post was really useful to me. But is there a way where I can show the screen name (i.e. Twitter ID / Facebook ID) as the url’s text ?

    For Example : Find me on Twitter @tospost { wherein tospost will contain the url added by the user at the backend }

  11. wphacks says:

    I pasted the exact function, no errors, and the fields appear as expected, however, upon save, the twitter line and the linkedin line do not save added field info. Facebook works, but the other two lines just erase the contents of the field upon save.


  12. [...] add new options, Thomas Griffin offered the following tip, which I’ve modified a bit, to add Twitter and Facebook via your Theme’s functions.php [...]

  13. Jan Bletz says:

    Thank you for this informative post.

    I have managed to do replace the fields I don’t need by other ones (facebook, twitter etc.). But where do I paste the code <a href="ID); ?>”> ?

    In the functions.php? Or in the authors.php?


    • Jan Bletz says:

      P.S. Or should I try the author.php ( I did, but it doesn’t work either). I’m using the suffusion theme, the author.php looks like this:

      $value) {
      $$id = $value;


      <a href="ID); ?>”>

      • Thomas Griffin says:

        Hi Jan,

        It would depend on where you want the code to appear. You could place it in either one of those files. You could also try this as well:

        < ?php echo get_the_author_meta( 'facebook', $current_author->ID ); ?>

        Hope this helps!

  14. [...] Advanced users would probably enjoy this class which allow you to manage user contact info easily. Source: [...]

  15. Hi Thomas, Great tip, instead of showing details for the current author though, I’d like to always display the administrators information – how would I go about doing that?

  16. Syed Abidur Rahman says:

    So many thanks for sharing this article with us. It saves time of the development. Thank you, again.

  17. Livelyjobs says:

    thanks a lot for sharing

  18. […] created some custom profile fields following the advice of Thomas Griffin ([ and Stephanie Leary […]

  19. […] How to Add Custom User Contact Info in WordPress, de Thomas […]

Leave a Reply