0

I am working on a site and it is possible that the site will have a number of pages which feature links to the client's social networking sites (Twitter, Facebook, LinkedIn...).

Now I know that the URLs to their profile shouldn't change too often, but they would like the option to update the URLs if they ever needed to.

My question is what the best method would be to allow my client to simply visit one page in the Admin area where they can copy and paste the new URLs into the fields for each social media site?

I thought about using Custom fields, but I guess there must be a way I can create a small widget that just allows me to echo whatever has been placed in the fields for each social media site. That way I can just echo that particular widget in the 'href' of the social media button and I can use it anywhere I want in my theme files.

Problem is, I don't delve much into custom widgets yet and I am not sure whether 1) it's the best way to achieve this and 2) Whether you can create a widget that simply allows you to echo whatever has been place in that field (almost just like a custom field).

Any clarification would be greatly appreciated.

Thanks,

1 Answer 1

0

The best way is on the user profile page using the contact methods extension:

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

This adds fields to the user profile page for those social networks. You can have as many as you like, then you can use that data in a widget or via a template tag in the following way:

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

Actually writing the widget or template tag is a separate question though.

3
  • Adding this to my functions.php doesn't seem to change anything. Am I right in thinking that I should be able to see the fields in the Users > Your Profile page?
    – remi90
    Commented Oct 31, 2011 at 12:04
  • Silly me, it works, I was editing a different functions.php file I have open in my editor. Thank you sancho :)
    – remi90
    Commented Oct 31, 2011 at 12:13
  • @remi90 ah! No problem Commented Oct 31, 2011 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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