X

How to Add Contact Methods to Profile, Twitter, Facebook, Flickr

Snippets by IsItWP

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.

Comments   Leave a Reply

  1. 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’]);

    1. Try ‘user_url’

  2. add_filter(‘user_contactmethods’,’add_remove_contactmethods’,10,1);Is causing issues.

    1. Hi Danni what problems are you encountering?

  3. 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

    1. @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;

  4. Interesting… but how to display this information on the site in the profiles of your members?!

    1. Place this into your template to display the information.

             get_the_author_meta($curauth->ID);
             echo $curauth->facebook;

  5. ????????? ??????? March 18, 2011 at 6:23 am

    wow great .. thanks

    1. No problem, glad you like the snippet,

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!