Opened 20 months ago
Last modified 4 weeks ago
#18709 new enhancement
Hooks in user-new.php
| Reported by: |
|
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)
Change History (16)
- Version changed from 3.3 to 3.2.1
comment:2
SergeyBiryukov — 20 months ago
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.
comment:4
follow-up:
↓ 5
strangerstudios — 18 months ago
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
DrewAPicture — 18 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.
comment:6
aaroncampbell — 16 months ago
- 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.
comment:9
SergeyBiryukov — 11 months ago
Related/duplicate: #13548
comment:10
stephenh1988 — 11 months ago
- Cc contact@… added
comment:11
knutsp — 6 months ago
- Cc knut@… added
comment:12
mtekk — 5 months ago
- Cc mtekkmonkey@… added
comment:13
andyadams — 3 months ago
- Cc andyadamscp@… added
comment:14
RyanGannon — 2 months ago
- Cc RyanGannon added
comment:15
versusbassz — 4 weeks ago
- Cc versusbassz added

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