Last active
October 8, 2015 06:39
-
-
Save sunnyluthra/b25f8a5fe4d9915725df to your computer and use it in GitHub Desktop.
WordPress get user by metakey and value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_user_id_by_meta($key, $value) { | |
if (!$key && !$value) { | |
return false; | |
} | |
$args = array( | |
'meta_key' => $key, | |
'meta_value' => $value, | |
'fields' => 'ids', | |
'count_total' => false, | |
); | |
$user = get_users($args); | |
return current($user); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment