Created
May 10, 2018 19:51
-
-
Save davidchc/ff616b9e0696e0227d5de612d4bd7f9a to your computer and use it in GitHub Desktop.
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_custom_field($field, $value){ | |
global $wpdb; | |
$prepare = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = %s ", $field, $value); | |
$row = $wpdb->get_row($prepare); | |
return isset($row->user_id) ? $row->user_id : 0; | |
} |
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 | |
$code = '21354Adcd'; | |
$user_id = get_user_id_custom_field('voucher', $code); | |
if($user_id) { | |
echo 'Voucher existente'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment