Are you looking for a way to add Twitter, Facebook, LinkedIn, and Flickr contact into user profiles? While there’s probably a plugin for this, we have created a quick code snippet that you can use to add contact methods to profile, Twitter, Facebook, Flickr in WordPress.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
function add_remove_contactmethods( $contactmethods ) { $contactmethods['twitter'] = 'Twitter'; $contactmethods['facebook'] = 'Facebook'; $contactmethods['linkedin'] = 'Linked In'; $contactmethods['flickr'] = 'Flickr'; // this will remove existing contact fields unset($contactmethods['aim']); unset($contactmethods['yim']); unset($contactmethods['jabber']); return $contactmethods; } add_filter('user_contactmethods','add_remove_contactmethods',10,1);
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 50+ best responsive WordPress themes to create a mobile-ready site and how to add a portfolio to your WordPress site.
Easy enough to add these things–anyone figured out a way to REMOVE ones that you don’t want–namely: Website. Neither of the following works:
unset($contactmethods[‘Website’]);
unset($contactmethods[‘url’]);
Try ‘user_url’
add_filter(‘user_contactmethods’,’add_remove_contactmethods’,10,1);Is causing issues.
Hi Danni what problems are you encountering?
hi kevin, well .. i’m hooked already with this genius website, a part that i’m not genius at the moment , my simple basic question , okay, we already created alot of fields ..and where the data storage goes at database, already checked table wp_users and..there’s nothing on it .. please advise ..thanks
@google-842df667d8aa359c307fc2f356644c63:disqus you don’t need to do anything but add this snippet to the functions.php of your wordpress theme.
You will then need a little bit of code to display it within your theme.
For the author add,
get_the_author_meta($curauth->ID);
echo $curauth->facebook;
Interesting… but how to display this information on the site in the profiles of your members?!
Place this into your template to display the information.
get_the_author_meta($curauth->ID);
echo $curauth->facebook;
wow great .. thanks
No problem, glad you like the snippet,