WordPress profiles include fields for contact methods, many of which aren’t used very often. It’s a legacy of early versions of WordPress. But the list is easily filterable, so we can change them to more useful fields.
This function lets you specify an array of contact methods you’d like removed, and those you’d like to add.
You can access your new contact methods in theme files like this: get_the_author_meta( 'linkedin' );
<?php | |
/** | |
* Update Contact Methods | |
* | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/add-remove-contact-methods/ | |
*/ | |
function be_contact_methods( $contactmethods ) { | |
$remove = array( 'aim', 'yim', 'jabber' ); | |
foreach( $remove as $service ) { | |
if( isset( $contactmethods[$service] ) ) { | |
unset( $contactmethods[$service]); | |
} | |
} | |
$add = array( | |
array( | |
'service' => 'linkedin', | |
'label' => 'LinkedIn URL', | |
), | |
array( | |
'service' => 'netvibes', | |
'label' => 'Netvibes URL', | |
), | |
array( | |
'service' => 'twitter', | |
'label' => 'Twitter URL' | |
), | |
); | |
foreach( $add as $item ) { | |
if( !isset( $contactmethods[$item['service']] ) ) { | |
$contactmethods[$item['service']] = $item['label']; | |
} | |
} | |
return $contactmethods; | |
} | |
add_filter( 'user_contactmethods', 'be_contact_methods' ); |