#20095 closed defect (bug) (worksforme)
get_users() doesn't allow hyphens in meta_key parameter
Reported by: | mordauk | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.3.1 |
Component: | Users | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
When retrieving users with the get_users() function, the meta_key parameter does not work if the key contains a hyphen (dash).
For example:
$members = get_users(array( 'meta_key' => 'job-seeking', 'meta_value' => 1, ) );
That will result in no members being found, even though at least one user with a meta_key of "job-seeking" with a value of 1 does exist.
This, however, will work:
$members = get_users(array( 'meta_key' => 'job_seeking', 'meta_value' => 1, ) );
Change History (4)
#2
@
13 years ago
- Keywords changed from needs-testing, reporter-feedback to needs-testing reporter-feedback
It's not, it definitely has the hyphen.
Doing get_user_meta($user_id, 'job-seeking', true) works fine (returns the value).
Doing update_user_meta($user_id, 'job-seeking', 1) also works fine and saves the data.
I've also just looked through the usermeta table and there are lots of keys with hyphens, so they're not getting normalized upon creation. At least as far as I can tell.
Note: See
TracTickets for help on using
tickets.
Can you clarify if the meta key is
job-seeking
orjob_seeking
in the database data?It might just be that meta keys are normalized.