WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a WordPress plugin and I want to append some extra form fields in add new form of Users section inside admin panel without editing core files. Can somebody help me in achieving this.

share|improve this question

You will find a lot of tutorials for doing this, take a look here for example : http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields

You can use following hooks : show_user_profile, edit_user_profile, personal_options_update, edit_user_profile_update ...

EDIT : But it will not add fields on the "New User" form since there is no hook for that : http://core.trac.wordpress.org/browser/branches/3.3/wp-admin/user-new.php

But you can :

  • try to add needed fields using javascript, and use user_register hook to add user meta data in db.
  • Or build your own form.
share|improve this answer
    
I want to add form fields on new user registration form i.e on "add new" page of users section. The link only shows how to add such functionality on "edit-user" and "your profile" page of users section. – Krishna Apr 19 '12 at 8:35
    
Sorry, answer updated. – soju Apr 19 '12 at 8:51
    
please don't answer just because you have to. read the question properly. – Hasin Hayder Oct 2 '12 at 3:27
    
Please don't comment if you don't have any useful information to give. – soju Oct 2 '12 at 6:41
2  
That's the point of this site, to ask, to answer. Sometimes we make mistakes. That's what down-voting is for, in cases where bad advice/incorrect answers are given, assuming the user doesn't make the effort to correct his/her answer. But without genuine contributions from users this resource doesn't exist. Point in case, if Soju didn't answer this question, it'd still be unanswered. Now who does that help? – userabuser Oct 29 '12 at 14:41

You can use this filter to add your fields:

apply_filters( 'show_password_fields', true );
add_filter( 'show_password_fields', 'yourfunction', 10, 1 );
function yourfunction( $return ) {
    ?><tr>
        <th><label for="gender">Gender</label></th>
        <td>
            <label><input type="radio" name="w4p_user_gender" value="male" class="regular-radio" />Male</label>
            <label style="margin-left:10px"><input type="radio" name="w4p_user_gender" value="female" class="regular-radio" />Female</label><br/>
            <span class="description">Please select your Gender.</span>
        </td>
    </tr><?php
    return $return;
}

I don't know if it's a good idea or not, but it works for me. :)

share|improve this answer
    
But, does this works for custom user meta? As far as I tested, only for default user meta... Are you doing something like this? – brasofilo Dec 5 '12 at 15:53

As of WordPress 3.0.0 this action is available at the top of the new user form:

user_new_form_tag

As of WordPress 3.7.0 this action is called at the end of the form (right before submit button):

user_new_form

You will however need to intercept when clicking submit to save any specific user information to the user's meta

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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