Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The user profile page has the following fields:

Username
First Name
Last Name
Nickname Display name Contact Info E-mail Website AIM Yahoo IM
Jabber / Google Talk

How can more fields be added to this section. Field such as Phone number, address, or anything else.

share|improve this question
add comment

2 Answers

up vote 14 down vote accepted

Hi @Raj Sekharan:

You need to use the 'show_user_profile', 'edit_user_profile', 'personal_options_update' and 'edit_user_profile_update' hooks.

Here's some code to add a Phone number:

add_action( 'show_user_profile', 'yoursite_extra_user_profile_fields' );
add_action( 'edit_user_profile', 'yoursite_extra_user_profile_fields' );
function yoursite_extra_user_profile_fields( $user ) {
?>
  <h3><?php _e("Extra profile information", "blank"); ?></h3>
  <table class="form-table">
    <tr>
      <th><label for="phone"><?php _e("Phone"); ?></label></th>
      <td>
        <input type="text" name="phone" id="phone" class="regular-text" 
            value="<?php echo esc_attr( get_the_author_meta( 'phone', $user->ID ) ); ?>" /><br />
        <span class="description"><?php _e("Please enter your phone."); ?></span>
    </td>
    </tr>
  </table>
<?php
}

add_action( 'personal_options_update', 'yoursite_save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'yoursite_save_extra_user_profile_fields' );
function yoursite_save_extra_user_profile_fields( $user_id ) {
  $saved = false;
  if ( current_user_can( 'edit_user', $user_id ) ) {
    update_user_meta( $user_id, 'phone', $_POST['phone'] );
    $saved = true;
  }
  return true;
}

That code will add a field to your user screen that looks something like this:

There are also several blog posts available on the subject that might be helpful:

Or if you prefer not to roll-your-own there are plugins that add said features such as the following (although I'm sure there are others):

share|improve this answer
    
------>mike rocks! –  rsman Dec 2 '10 at 9:03
    
@Raj Sekharan - You are too kind. :) –  MikeSchinkel Dec 2 '10 at 10:23
    
Mike, I ran into a bunch of trouble get my modifications to save. I finally nailed it when I did a complete "find and replace". For my future reference, are the "name" and "title" fields required to be an exact match? –  Jonathan Wold Mar 28 '11 at 16:43
    
@Jonathan Wold - "are the "name" and "title" fields required to be an exact match?" You didn't give me enough context for me to know how to aswer. And you may want to create a complete new question. –  MikeSchinkel Mar 29 '11 at 7:26
    
@MikeSchinkel Cimy User Extra Fields is imo no good recommendation. Support isn't really there and the code is ... hm. –  kaiser Aug 25 '11 at 22:07
add comment
// remove aim, jabber, yim 
function hide_profile_fields( $contactmethods ) {
    unset($contactmethods['aim']);
    unset($contactmethods['jabber']);
    unset($contactmethods['yim']);
    return $contactmethods;
}

// add anything else
function my_new_contactmethods( $contactmethods ) {
    //add Birthday
    $contactmethods['birthday'] = 'Birthday';
    //add Address
    $contactmethods['address'] = 'Address';
    //add City
    $contactmethods['city'] = 'City';
    //add State
    $contactmethods['state'] = 'State';
    //add Postcode
    $contactmethods['postcode'] = 'Postcode';
    //add Phone
    $contactmethods['phone'] = 'Phone';
    //add Mobilphone
    $contactmethods['mphone'] = 'Mobilphone';

    return $contactmethods;
}
add_filter('user_contactmethods','my_new_contactmethods',10,1);
add_filter('user_contactmethods','hide_profile_fields',10,1);

Hope this helps.

Source: WPBeginner

share|improve this answer
add comment

protected by toscho Sep 29 '13 at 18:57

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.