#41950 closed enhancement (fixed)
wp_insert_user() should accept a meta_input argument
Reported by: | desrosj | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | normal | Version: | 2.0 |
Component: | Users | Keywords: | has-patch has-unit-tests needs-dev-note |
Focuses: | Cc: |
Description
wp_insert_user()
does insert user meta, but only meta generated by the function (nickname
, first_name
, etc.), or added to that list by using the insert_user_meta
filter.
It would be nice to be able to pass the additional meta to the function when called, like in wp_insert_post()
.
Change History (9)
This ticket was mentioned in PR #1177 on WordPress/wordpress-develop by donmhico.
4 years ago
#2
- Keywords has-patch has-unit-tests added; needs-patch removed
This PR allows the addition of meta_input
key in $userdata
args in wp_insert_user( $userdata )
to add user meta. Like how wp_insert_post()
allows meta_input
.
Trac ticket: https://core.trac.wordpress.org/ticket/41950
#3
@
4 years ago
I attached a PR that should address this enhancement requests. One thing to note though.
I decided to have a separate filter for the meta_input
, usage - apply_filters( 'insert_user_custom_meta', $custom_meta, $user, $update );
instead of using the existing filter - apply_filters( 'insert_user_meta', $meta, $user, $update );
.
The main reason is to just not touch that filter and prevent any possible backward compat issue. And to also have different filters between built-in user meta and custom ones.
Any feedback is welcome.
#4
@
4 years ago
- Milestone changed from Awaiting Review to 5.8
- Owner set to johnbillion
- Status changed from new to reviewing
#5
@
4 years ago
- Milestone changed from 5.8 to 5.9
Today is the feature cut off for 5.8. I'm going to punt this to 5.9 with the intention of returning for that cycle.
Thanks for the work here so far! We'll get this one attention soon!
#6
@
3 years ago
The PR at https://github.com/WordPress/wordpress-develop/pull/1177 all looks good to me. I agree that separating the filters makes sense.
I've refreshed the branch and tweaked the docs. If the tests pass then this is ready to go.
This sounds like a good candidate for a filter. We shouldn’t support non-core meta in core but should allow plugins to hook in and define their own.