Displaying additional User Contact Information

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.

Read More

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?

<?php 
    $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>

Related posts

Leave a Reply

2 comments

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

    /* BEGIN Custom User Contact Info */
     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');
     /* END Custom User Contact Info */
    

    Displaying it:

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

    http://thomasgriffinmedia.com/blog/2010/09/how-to-add-custom-user-contact-info-in-wordpress/

  2. // 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
        unset($contactmethods['aim']);
        unset($contactmethods['yim']);
        return $contactmethods;
    }
    add_filter('user_contactmethods','add_remove_contactmethods',10,1);
    

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

    http://wpsites.net/how-to-wordpress/how-to-addremove-custom-user-profile-contact-info-links-to-your-author-box/