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="<?php echo $twitter ?>" id="twitterBtn" title="Visit our Twitter page">Visit our Twitter page</a>

没有正确的解决方案

许可以下: CC-BY-SA归因
scroll top