How To Extend User Contact Info in WordPress

WordPress 2.9 was built with the new ability to extend the User Contact Info fields, this trick can be done by adding some code on functions.php within your current theme.

We can add lots of contact information, depending upon your needs. To extend user contact info, open the files and add in this code

1
2
3
4
5
6
7
8
9
10
11
<?php
function my_new_contactmethods( $contactmethods ) {
    // Add Twitter
    $contactmethods['twitter'] = 'Twitter';
    //add Facebook
    $contactmethods['facebook'] = 'Facebook';
    return $contactmethods;
}
add_filter('user_contactmethods','my_new_contactmethods',10,1);
?>

And the result of this trick will be like this,

Extend-WordPress-User-Info-460x281

This is only a basic example and you can make it more complicated depending on your creative needs 😉

5 thoughts on “How To Extend User Contact Info in WordPress

  1. Hey Whil, to remove a field, just ‘unset’ the value from the $contactmethod object.

    function modify_user_contact_methods( $user_contact ) {

    // Add user contact methods
    $user_contact['skype'] = __( 'Skype Username' );
    $user_contact['twitter'] = __( 'Twitter Username' );

    // Remove user contact methods
    unset( $user_contact['aim'] );
    unset( $user_contact['jabber'] );

    return $user_contact;
    }
    add_filter( 'user_contactmethods', 'modify_user_contact_methods' );

    http://codex.wordpress.org/Plugin_API/Filter_Reference/user_contactmethods

  2. You need to paste following code in template file
    twitter; ?>

    And if you want to display on author page with link then add below code in author.php file
    <a href="http://twitter.com/twitter; ?>" target="_blank">twitter; ?>

    Many Thanks!

Leave a Reply

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