Hack: Add More User Contact Methods

If you look at user profiles in WordPress, there is a section called Contact Info. By default, there is a field for an email address and a Website. But you can change this using a simple bit of code in your functions.php file or custom plugin.

The hook to use here is user_contactmethods. An array with a list of contact field names is passed in. You can add to it, or even remove items. Then return the new array. Here is an example that adds a Twitter field and a Facebook field.

add_filter('user_contactmethods', 'wpfilter_contactmethods');
function wpfilter_contactmethods($contactmethods) {
	$contactmethods['Twitter'] = 'Twitter';
	$contactmethods['Facebook'] = 'Facebook';
	return $contactmethods;
}

Removing can be done with unset, but unfortunately the Website field can’t be removed that way.

Leave a Reply

Your email address will not be published. Required fields are marked *