I have variable $var which is dynamic. I want to find if there are any matches of this variable in custom user meta - "authmeta" and return the user_id of the corresponding entry if any matches are found.

  • Where and when do want to find this?
    – alpipego
    Aug 10, 2015 at 7:04
  • $var is a custom query variable and i want to find if it matches to any user meta of a user and if so i want to get the user id. Aug 10, 2015 at 7:11

1 Answer 1


You can use WP user query.

Assuming that your meta_key is authmeta you can use the following code to find the users with meta key authmeta and value of your $var variable.

$user_query = new WP_User_Query( array( 'meta_key' => 'authmeta', 'meta_value' => $var ) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.