Sunday, July 7, 2013

How to Add or remove contact info fields in WordPress

Users in WordPress by default have profiles and in every profile you will find these fields for Contact Info, by default: E-mail, Website, AIM, Yahoo IM, Jabber / Google Talk. You can remove those and add new ones as you wish, Here code exemple for your functions.php file in your theme:

function new_contactmethods( $contactmethods ) {
$contactmethods['twitter'] = 'Twitter'; // Add Twitter field
$contactmethods['facebook'] = 'Facebook'; // Add Facebook field
unset($contactmethods['yim']); // Remove YIM field
unset($contactmethods['aim']); // Remove AIM field
unset($contactmethods['jabber']); // Remove Jabber field

return $contactmethods;


If you want display that publicly in your template add this code :

$user_id = 1;
$key = 'twitter';
$single = true;

$user_twitter = get_user_meta( $user_id, $key, $single);

echo $user_twitter; // add twitter field of user where id = 1

Disqus Comments