WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been advised how to add additional contact info fields to the User admin area here (Click here).

However, I am not entirely sure how I can display the the field contents in a link within my template files.

Here is the code in my functions.php:

add_filter( 'user_contactmethods', 'more_contactmethods' );
function more_contactmethods( $contactmethods ) {
    $contactmethods['twitter'] = 'Twitter URL';
    $contactmethods['facebook'] = 'Facebook URL';
    $contactmethods['linkedin'] = 'LinkedIn URL';
    return $contactmethods;

And here's the code in one of my template files, but it doesn't seem to work, so I wonder whether I can actually do it this way?

    $twitter = get_usermeta( $user_id, 'facebook' ); 
    $facebook = get_usermeta( $user_id, 'twitter' );
    $linkedin = get_usermeta( $user_id, 'linkedin' );

    <a href="<?php echo $twitter ?>" id="twitterBtn" title="Visit our Twitter page">Visit our Twitter page</a>
share|improve this question
get_usermeta has been depreciated and replaced with get_user_meta. Also can you verify $user_id has a value? – v0idless Oct 31 '11 at 14:56
I'm actually a bit confused by this now...sure there is a value for $user_id? Also, why wouldn't <?php echo ($contactmethods['twitter']) ?> work? – remi90 Oct 31 '11 at 15:36
The $contactmethods array is only available when you use the user_contactmethods filter. To access the user metadata, you need to use the get_user_meta function. Can you actually verify the data is getting into the database? You may need to hook personal_options_update and edit_user_profile_update to actually save the data. – v0idless Oct 31 '11 at 16:14
What does a <?php var_dump( get_user_meta( $user_id, 'user_contactmethods' ) ); ?> return? – Chip Bennett Oct 31 '11 at 20:43
up vote 2 down vote accepted

This might help you out if you haven't found an answer yet.

/* 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 */

Displaying it:

<a href="<?php the_author_meta('facebook', $current_author->ID); ?>"></a>


share|improve this answer
// Add/Remove Contact Methods
function add_remove_contactmethods( $contactmethods ) {
    $contactmethods['twitter'] = 'Twitter';
    $contactmethods['facebook'] = 'Facebook';
    $contactmethods['Youtube'] = 'YouTube';
    $contactmethods['linkedin'] = 'LinkedIn';
        $contactmethods['skype'] = 'Skype';
    // Remove Contact Methods
    return $contactmethods;

This works fine in Thesis. Here's the full tutorial


share|improve this answer
Thanks @BradDalton, I think I'm having trouble with the code to actually echo the value though. Can you help with this? – remi90 Oct 31 '11 at 20:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.