From 7f0dd54d0b2ef397a8687ef0c2f7b3f836e3549e Mon Sep 17 00:00:00 2001 From: champsupertramp Date: Tue, 1 Mar 2016 18:51:48 +0800 Subject: [PATCH] Add function to check meta value existence by meta key --- core/um-short-functions.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/um-short-functions.php b/core/um-short-functions.php index 3c9d86a3..44fc16a4 100644 --- a/core/um-short-functions.php +++ b/core/um-short-functions.php @@ -1397,3 +1397,21 @@ function um_fetch_user( $user_id ) { return $protocol; } + /** + * Check if meta_value exists + * @param string $key + * @param mixed $value + * @return integer + */ + function um_is_meta_value_exists( $key, $value ){ + global $wpdb; + + $count = $wpdb->get_var( $wpdb->prepare( + "SELECT COUNT(*) as count FROM {$wpdb->usermeta} WHERE meta_key = %s AND meta_value = %s ", + $key, + $value + ) ); + + return $count; + } +