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?

<?php 
    $twitter = get_usermeta( $user_id, 'facebook' ); 
    $facebook = get_usermeta( $user_id, 'twitter' );
    $linkedin = get_usermeta( $user_id, 'linkedin' );
?>

    <a href="https://wordpress.stackexchange.com/questions/32505/<?php echo $twitter ?>" id="twitterBtn" title="Visit our Twitter page">Visit our Twitter page</a>

2 Answers
2

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="https://wordpress.stackexchange.com/questions/32505/<?php the_author_meta("facebook', $current_author->ID); ?>"></a>

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

Leave a Reply

Your email address will not be published. Required fields are marked *