For some reason during a user query with a meta filter I have a user who when I print_r
the results appears twice in the list...
I have checked the database, just in case there seemed to be duplicate entries but there is only a single value for the user. Also without the meta query the user only appears once.
Code:
$user_query = new WP_User_Query(
array(
'role' => 'member',
'orderby' => 'registered',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'onTrial',
'value' => '1',
),
),
)
);
echo '<pre>';
print_r($user_query->results);
echo '</pre>';
Outputs (along with many others):
[54] => WP_User Object
(
[data] => stdClass Object
(
[ID] => 10410
[user_login] => [email protected]
[user_pass] => $P$XXXXXXX
[user_nicename] => XXXXXXX-XXXXXXX
[user_email] => [email protected]
[user_url] =>
[user_registered] => 2016-02-15 10:52:57
[user_activation_key] =>
[user_status] => 0
[display_name] => XXXXXXX XXXXXXX
)
[ID] => 10410
[caps] => Array
(
[member] => 1
)
[cap_key] => wp_capabilities
[roles] => Array
(
[0] => member
)
[allcaps] => Array
(
[read] =>
[no_admin_bar] => 1
[member] => 1
)
[filter] =>
)
[55] => WP_User Object
(
[data] => stdClass Object
(
[ID] => 10410
[user_login] => [email protected]
[user_pass] => $P$XXXXXXX
[user_nicename] => XXXXXXX-XXXXXXX
[user_email] => [email protected]
[user_url] =>
[user_registered] => 2016-02-15 10:52:57
[user_activation_key] =>
[user_status] => 0
[display_name] => XXXXXXX XXXXXXX
)
[ID] => 10410
[caps] => Array
(
[member] => 1
)
[cap_key] => wp_capabilities
[roles] => Array
(
[0] => member
)
[allcaps] => Array
(
[read] =>
[no_admin_bar] => 1
[member] => 1
)
[filter] =>
)
Now I can't show you the details obviously but note the ID and reg time outputted also the array numbers they appear in, [54]
and [55]
No one else appears twice.
Thanks in advance - any input appreciated, small or large.
umeta_id
s despite that particular bit of code usingupdate_user_meta
as an insert command. I didn't spot it before as to check I was usingforeach(
[get_user_meta($profileuser->ID)]as $key => $value) {
How will that have happened?wp_cron
. If it's adding multiple values on the user meta then that query sort of breaks down as useless and relies me spotting duplicates manually or usingarray_unique
for everything... Which is annoying.