0

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.

1

3 Answers 3

1

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

0

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.
5
  • 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
    Commented Apr 19, 2012 at 8:35
  • Sorry, answer updated.
    – soju
    Commented Apr 19, 2012 at 8:51
  • please don't answer just because you have to. read the question properly. Commented Oct 2, 2012 at 3:27
  • Please don't comment if you don't have any useful information to give.
    – soju
    Commented Oct 2, 2012 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?
    – Adam
    Commented Oct 29, 2012 at 14:41
0

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. :)

1
  • 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
    Commented Dec 5, 2012 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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