Opened 10 years ago
Closed 9 years ago
#31549 closed enhancement (fixed)
filter meta array in wp_insert_user
Reported by: | tharsheblows | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Users | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Could a filter be added to the $meta array before inserting it into usermeta?
I don't use some of the meta keys and looked and saw they're safe to delete, but realised I can't actually stop them from being set. The reason I'm asking is that count_users is getting very slow for me (I have 110k users), so I'm coming at that from a couple of different directions.
Thanks.
Attachments (6)
Change History (19)
#2
@
10 years ago
Hi @tharsheblows, welcome to Trac!
The new filter you're suggesting will need hook docs to go along with it.
#3
@
10 years ago
Oops. I've added them in - let me know any typos / misunderstandings / mistakes. Thanks! :)
#4
@
9 years ago
- Keywords needs-refresh added; has-patch removed
- Milestone changed from Awaiting Review to 4.4
- Owner set to chriscct7
- Status changed from new to assigned
This patch needs a refresh for the version in the doc hook and some sanity checks. Will get a revised patch up and going when I get a chance
#5
@
9 years ago
- Keywords has-patch commit added; needs-refresh removed
- Status changed from assigned to accepted
- Version 4.2 deleted
Looks good to go.
#6
@
9 years ago
- Owner changed from chriscct7 to DrewAPicture
- Status changed from accepted to assigned
#8
@
9 years ago
- Owner changed from DrewAPicture to wonderboymusic
31549.patch fixes some of the types and formatting in the hook docs. Otherwise look good to go.
#9
@
9 years ago
I'm not sure I would cast to array - maybe check after for ! $meta
and then set to array()
- I'll think about it
php > $a = null; php > $b = (array) $a; php > var_dump( $b ); array(0) { } php > $a = false; php > $b = (array) $a; php > var_dump( $b ); array(1) { [0]=> bool(false) } php >
#11
@
9 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Since it's the same for inserting new user and updating one, there's no safe way to see if the empty meta such as description
is actually initiated empty or must be deleted on this update.
thinking the whole point if the filter is to bypass saving empty meta upon registration.
suggesting pass full info to the filter, i.e. $update
add filter to meta array in wp_insert_user