Customizing WordPress User Contact Info Fields

WordPress User Profile PanelIt is a fact that instead of held full-filled handy user contact info, the Contact info section under User Profile panel on WordPress dashboard helds an always empty fields of AIM, Yahoo IM and Jabber / Google Talk.

And instead spent even a minute of thinking about what to fill in and why the outdated AIM, Yahoo IM and Jabber / Google Talk’s become standard on WordPress, spending a minute of coding-work to get the such fields customized will be your better thing to do.

No more outdated user contact methods and no more the 3 always empty user contact info fields hanging around under your Contact info section.

Remove User Contact Info Fields

Removing the 3 always empty user contact info fields is a very easy work, what you have to do is save the below function code to your function.php:

// Remove default contact info fields
function remove_default_contactmethod( $contactmethods ) { 
if ( isset( $contactmethods['yim'] ) ) 
unset( $contactmethods['yim'] ); 
if ( isset( $contactmethods['aim'] ) ) 
unset( $contactmethods['aim'] ); 
if ( isset( $contactmethods['jabber'] ) ) 
unset( $contactmethods['jabber'] );
return $contactmethods; 
}
add_filter( 'user_contactmethods', 'remove_default_contactmethod', 10, 1 );

Customize User Contact Info fields

The Customizing work of adding custom user contact info fields to the Contact info section is another easy story. Ex: adding tweeter, facebook and google+ contact info fields can simply be done by saving the below function code to your function.php :

// Adds custom contact info fields
function add_custom_contactmethod( $contactmethods ) { 
if ( !isset( $contactmethods['twitter'] ) ) 
$contactmethods['twitter'] = 'Twitter'; 
if ( !isset( $contactmethods['facebook'] ) ) 
$contactmethods['facebook'] = 'Facebook';
if ( !isset( $contactmethods['googleplus'] ) ) 
$contactmethods['googleplus'] = 'Google Plus';  
return $contactmethods; 
} 
add_filter( 'user_contactmethods', 'add_custom_contactmethod', 10, 1 );

Putting It All Together

Instead of having two separated functions of remove and add action, you could simply put the above two functions into one, by merging it and giving it a new label or prefix. Ex: you label it add_mycustom_contactmethod

// Adds custom contact info
function add_mycustom_contactmethod( $contactmethods ) { 
if ( !isset( $contactmethods['twitter'] ) ) 
$contactmethods['twitter'] = 'Twitter'; 
if ( !isset( $contactmethods['facebook'] ) ) 
$contactmethods['facebook'] = 'Facebook';
if ( !isset( $contactmethods['googleplus'] ) ) 
$contactmethods['googleplus'] = 'Google Plus'; 
if ( isset( $contactmethods['yim'] ) ) 
unset( $contactmethods['yim'] ); 
if ( isset( $contactmethods['aim'] ) ) 
unset( $contactmethods['aim'] ); 
if ( isset( $contactmethods['jabber'] ) ) 
unset( $contactmethods['jabber'] ); 
return $contactmethods; 
} 
add_filter( 'user_contactmethods', 'add_mycustom_contactmethod', 10, 1 );

Cheers…!

Thanks to: Joost de Valk for the simple coding!

About Sulistyo

a WordPress enthusiast, Jazz and Delta Blues addict, an Indonesian who tend to learn achieving a native-like level of English writing.