From 2f4f1740e662188c2dc9f5d39832d716c86a8fe1 Mon Sep 17 00:00:00 2001 From: champsupertramp Date: Thu, 10 Dec 2015 17:44:32 +0800 Subject: [PATCH] Fixed unique key field validation --- core/um-actions-form.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/um-actions-form.php b/core/um-actions-form.php index 69546af2..8ead6541 100644 --- a/core/um-actions-form.php +++ b/core/um-actions-form.php @@ -365,6 +365,25 @@ } break; + + case 'unique_value': + + if ( $args[$key] != '' ) { + + $args_unique_meta = array( + 'meta_key' => $key, + 'meta_value' => $args[ $key ], + 'compare' => '=', + 'exclude' => array( $args['user_id'] ), + ); + + $meta_key_exists = get_users( $args_unique_meta ); + + if( $meta_key_exists ){ + $ultimatemember->form->add_error( $key , __('You must provide a unique value','ultimatemember') ); + } + } + break; }