WordPress tip: Add extra contact methods to user profiles

February 16, 2012 at 3:08 pm

By default, WordPress allows you to enter some contact information on your user profile. For example, you can enter your aim or jabber screenname. But what about newer sites such as Twitter or Facebook? Here is a simple recipe to add new contact methods to your user profile.

Nothing complicated: Just paste the following code into your function.php file. Edit lines 4 and 5 according to your needs.

add_filter('user_contactmethods', 'my_user_contactmethods');

function my_user_contactmethods($user_contactmethods){
  $user_contactmethods['twitter'] = 'Twitter Username';
  $user_contactmethods['facebook'] = 'Facebook Username';

  return $user_contactmethods;
}

Hungry for code snippets? I just opened a snippet library on CatsWhoCode, which include lots of WordPress snippets. Have a look, and don’t hesitate to submit yours!

Thanks to TutsPlus for the cool tip!

Tags: