Quick Tip: Add Extra Contact Methods to User Profiles
If you Google “add extra fields to WordPress user profile” you’ll find all sorts of involved coding examples for adding extra inputs to the user profile page so you can capture additional user information. But if all you want to do is expand the default contact methods section then there’s a much simpler way to go.
The user_contactmethods Filter
The user_contactmethods filter allows you to set and unset the contact info fields on the user profile page. The great thing about using this method is that WordPress looks after the creation and updating of the fields.
Let’s add fields for Twitter and Facebook info. Put this in your functions.php file:
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;
}
Here is what you’ll get:

If you want to remove some fields, just unset them from the array:
function my_user_contactmethods($user_contactmethods){
unset($user_contactmethods['yim']);
unset($user_contactmethods['aim']);
unset($user_contactmethods['jabber']);
$user_contactmethods['twitter'] = 'Twitter Username';
$user_contactmethods['facebook'] = 'Facebook Username';
return $user_contactmethods;
}

To display the user’s info, simply use the get_user_meta function.
echo get_user_meta(1, 'twitter', true);
This will show the Twitter username for the user with an ID of 1. The true argument causes the data to be returned as a single value as opposed to an array.
That’s all there is to it!


Pingback: Quick Tip: Add Extra Contact Methods to User Profiles | Shadowtek | Hosting and Design Solutions
Pingback: WordPress tip: Add extra contact methods to user profiles
Pingback: WordPress tip: Add extra contact methods to user profiles | Wordpress Webdesigner
Pingback: WordPress tip: Add extra contact methods to user profiles | Best Web Consulting company in Nashik, India with Creative and Professional Website Design, Content Management Systems, Wordpress Experts, Ecommerce SEO, and more..
Pingback: 15 Fresh and Useful Wordpress Hacks/Snippets | gonzoblog.nl
Pingback: Как добавить новое поле в Профиль пользователя WordPress | Wordpresso
Pingback: WordPress tip: Add extra contact methods to user profiles
Pingback: WordPress tip: Add extra contact methods to user profiles | Cheap Website
Pingback: إضافة طرق تواصل أكثر في حسابك للوردبريس | Pro BloG
Pingback: WordPress tip: Add extra contact methods to user profiles | Eagle Web Tech LLC :: Web Enabled Technical Solutions :: Martinsburg, WV
Pingback: Super useful WordPress action hooks and filters | PHP Developer Resource
Pingback: Super useful WordPress action hooks and filters | Easy jQuery | Free Popular Tips Tricks Plugins API Javascript and Themes
Pingback: Super useful WordPress action hooks and filters « The Blog of Jordan Rynard
Pingback: Lägg till och ta bort fält i profilen ‹ Wordpress
Pingback: Add and remove fields in the profile ‹ Wordpress @en
Pingback: Quick Tip: Add Extra Contact Methods to User Profiles | Wptuts+ » Web Design
Pingback: Super useful WordPress action hooks and filters | web design resources | freebies | tutorials
Pingback: 10 Useful WordPress Hacks And WordPress Functions - WPShock
Pingback: Super useful WordPress action hooks and filters | CatsWhoCode.com
Pingback: Super useful WordPress action hooks and filters | Kapun.ORG
Pingback: 10 WordPress Code Snippets that Replace Plugin Functionality - ManageWP
Pingback: 워드프레스 유용한 functions.php 코드 모음 2 » 씨제이스토리
Pingback: Share Delicious Knowledge Super useful WordPress action hooks and filters | Share Delicious Knowledge
Pingback: Wordpress Kullanıcı profillerine yeni alanlar ekleyin - Berkay GELDEC
Pingback: Remove or add additional information to WordPress user profiles
Pingback: Add extra contact methods to user profiles: WordPress Tips!
Pingback: 10 Useful WordPress Hacks And WordPress Functions | funneyzone
Pingback: 워드프레스 유용한 functions.php | 아이블로그