Opened 20 months ago

Last modified 4 weeks ago

#18709 new enhancement

Hooks in user-new.php

Reported by: standardtoaster Owned by:
Priority: normal Milestone: Awaiting Review
Component: Administration Version: 3.2.1
Severity: normal Keywords: dev-feedback
Cc: aaroncampbell, info@…, scott@…, contact@…, knut@…, mtekkmonkey@…, andyadamscp@…, RyanGannon, versusbassz

Description

It would be nice to be able to enter extra metadata for users when manually creating them from the admin control panel.

I assume it should be as simple as adding a new action, along the lines of the edit_user_profile_update one?

Attachments (1)

new-user-profile.diff (443 bytes) - added by strangerstudios 18 months ago.
Diff to add a "new_user_profile" action to user-new.php

Download all attachments as: .zip

Change History (16)

  • Version changed from 3.3 to 3.2.1

Isn't that already possible by hooking to user_register and checking is_admin() if needed?

It looks like the user_register hook is called AFTER the form is filled out, making it unsuitable for requested user metadata during the account creation process.

I'd like to add fields to the new user form (in the admin interface only). the form appears to be statically defined in user-new.php.

Diff to add a "new_user_profile" action to user-new.php

I think the OP meant to add form fields and other code to the actual form in user-new.php... similar to "edit_user_profile" and "show_user_profile" in user-edit.php.

I'd like to do something similar, and wonder why this hook isn't in place already.

Attached is a patch which just adds a "new_user_profile" action above the roles. (FYI, I created the diff against 3.3-beta2-19067)

A hack to work around not having this hook is to use the "show_password_fields" hook/filter. That hook seems to only be used on the user-new.php and user-edit.php page. It's meant to check if the password field should be shown, but you can output code at that point to add things to the form. You can check FILE or $_SERVERPHP_SELF? to distinguish between the new/edit user pages.

comment:5 in reply to: ↑ 4   DrewAPicture18 months ago

Replying to strangerstudios:

I think the OP meant to add form fields and other code to the actual form in user-new.php... similar to "edit_user_profile" and "show_user_profile" in user-edit.php.

I'd like to do something similar, and wonder why this hook isn't in place already.

+1 for this. A lot of us have had to work around tacking fields on using the show_password_fields hook before.

  • Cc aaroncampbell added
  • Keywords dev-feedback added

I just recently had to hack fields into the user-new form using the 'show_password_fields' filter. It's hacky and not an ideal place for the fields. I'd love to see something like this make it in. I'd probably add it to the end of the form, just above the submit button, but where it is in the patch isn't too bad either.

  • Cc info@… added

Currently we have to use JavaScript or output buffering to add custom fields. A real hook would be very useful. The patch looks fine for me.

  • Cc scott@… added

Please can we have a hook here? WordPress has my my life more difficult due to the lack of hook at that point.

Related/duplicate: #13548

  • Cc contact@… added
  • Cc knut@… added
  • Cc mtekkmonkey@… added
  • Cc andyadamscp@… added
  • Cc RyanGannon added
  • Cc versusbassz added
Note: See TracTickets for help on using tickets.