I am trying to get a user by metakey
:
$user = get_users( array (
'meta_key' => 'token',
'meta_value' => $token,
'orderby' => 'meta_value',
'order' => 'DESC',
'number' => '10',
) );
This returns empty array, but there is a user with that meta key value.
$user = reset(
get_users(
array(
'meta_key' => 'token',
'meta_value' => $token,
'number' => 1,
'count_total' => false
)
)
);
This returns false
with a notice:
only variables should be passed by reference in
, but still there is a user with that value for the meta.
I need just to select a user FROM the current blog (to check, is it exists ) by metavalue. User in WordPress NETWORK, which is not attached to the current blog.
get_users
into areset
call, can you explain why? It's not good practice to nest function calls as it makes it difficult to debug problems. Have you verified$token
actually contains the correct value? How are you error checking the value ofget_users
to make sure it isn't aWP_Error
object with an error message?