@@ -83,12 +83,12 @@ public function output_admin_script() {
8383 endif ;
8484 }
8585
86- public function get_conditional_logic_options () {
86+ public function get_conditional_logic_options ( $ form_id = null ) {
8787
88- $ form_ids = 0 ;
88+ $ form_ids = $ form_id ? $ form_id : 0 ;
8989
9090 // Scope entry meta to the current form for GP Email Users and other admin screens
91- if ( is_admin () ) {
91+ if ( ! $ form_ids && is_admin () ) {
9292 if ( rgget ( 'page ' ) === 'gp-email-users ' ) {
9393 $ form_ids = rgpost ( '_gform_setting_form ' );
9494 if ( ! $ form_ids ) {
@@ -129,6 +129,38 @@ public function get_conditional_logic_options() {
129129 );
130130 }
131131 }
132+
133+ if ( function_exists ( 'gp_email_validator ' ) ) {
134+ $ email_fields = GFAPI ::get_fields_by_type ( $ form , 'email ' );
135+ foreach ( $ email_fields as $ field ) {
136+ if ( gp_email_validator ()->is_email_validator_field ( $ field ) ) {
137+ $ props = array (
138+ 'free ' => esc_html__ ( 'Is Free Email ' , 'gravityforms ' ),
139+ 'disposable ' => esc_html__ ( 'Is Disposable Email ' , 'gravityforms ' ),
140+ );
141+ foreach ( $ props as $ prop => $ label ) {
142+ $ options [ "gpev_is_ {$ prop }_ {$ field ->id }" ] = array (
143+ 'label ' => sprintf ( '%s (%s) ' , $ field ->label , $ label ),
144+ 'value ' => "gpev_is_ {$ prop }_ {$ field ->id }" ,
145+ 'operators ' => array (
146+ 'is ' => 'is ' ,
147+ 'isnot ' => 'isNot ' ,
148+ ),
149+ 'choices ' => array (
150+ array (
151+ 'text ' => esc_html__ ( 'Yes ' , 'gravityforms ' ),
152+ 'value ' => '1 ' ,
153+ ),
154+ array (
155+ 'text ' => esc_html__ ( 'No ' , 'gravityforms ' ),
156+ 'value ' => '0 ' ,
157+ ),
158+ ),
159+ );
160+ }
161+ }
162+ }
163+ }
132164 }
133165
134166 $ entry_meta = GFFormsModel::get_entry_meta ( $ form_ids );
@@ -197,7 +229,7 @@ public function get_payment_status_choices() {
197229
198230 public function set_rule_source_value ( $ source_value , $ rule , $ form , $ logic , $ entry ) {
199231
200- $ keys = array_keys ( $ this ->get_conditional_logic_options () );
232+ $ keys = array_keys ( $ this ->get_conditional_logic_options ( $ form [ ' id ' ] ) );
201233 $ target = $ rule ['fieldId ' ];
202234
203235 if ( in_array ( $ target , $ keys ) && $ entry ) {
@@ -206,7 +238,12 @@ public function set_rule_source_value( $source_value, $rule, $form, $logic, $ent
206238 // Fetch the latest from the database.
207239 $ entry = GFAPI ::get_entry ( $ entry ['id ' ] );
208240 }
209- $ source_value = rgar ( $ entry , $ rule ['fieldId ' ] );
241+
242+ if ( strpos ( $ target , 'gpev_is_ ' ) === 0 ) {
243+ $ source_value = $ this ->get_email_validator_result_value ( $ entry , $ target );
244+ } else {
245+ $ source_value = rgar ( $ entry , $ rule ['fieldId ' ] );
246+ }
210247 }
211248
212249 return $ source_value ;
@@ -239,6 +276,51 @@ public function get_runtime_entry_meta_keys() {
239276 return apply_filters ( 'gwclem_runtime_entry_meta_keys ' , array ( 'payment_status ' ) );
240277 }
241278
279+ public function get_email_validator_result_value ( $ entry , $ target ) {
280+
281+ if ( ! preg_match ( '/^gpev_is_(free|disposable)_(\d+)$/ ' , $ target , $ matches ) ) {
282+ return '' ;
283+ }
284+
285+ $ prop = $ matches [1 ];
286+ $ field_id = $ matches [2 ];
287+ $ services = array ( 'basic ' , 'kickbox ' , 'zerobounce ' );
288+ $ result = false ;
289+
290+ foreach ( $ services as $ service ) {
291+ $ data = gform_get_meta ( $ entry ['id ' ], "gpev_ {$ service }_result_ {$ field_id }" );
292+ if ( empty ( $ data ) || empty ( $ data ['metadata ' ] ) ) {
293+ continue ;
294+ }
295+
296+ $ meta = $ data ['metadata ' ];
297+
298+ if ( $ prop === 'free ' ) {
299+ if ( isset ( $ meta ['free ' ] ) ) {
300+ $ result = $ meta ['free ' ];
301+ } elseif ( isset ( $ meta ['is_free_email ' ] ) ) {
302+ $ result = $ meta ['is_free_email ' ];
303+ } elseif ( isset ( $ meta ['free_email ' ] ) ) {
304+ $ result = $ meta ['free_email ' ];
305+ }
306+ } elseif ( $ prop === 'disposable ' ) {
307+ if ( isset ( $ meta ['disposable ' ] ) ) {
308+ $ result = $ meta ['disposable ' ];
309+ } elseif ( isset ( $ meta ['is_disposable ' ] ) ) {
310+ $ result = $ meta ['is_disposable ' ];
311+ } elseif ( isset ( $ meta ['sub_status ' ] ) && $ meta ['sub_status ' ] === 'disposable ' ) {
312+ $ result = true ;
313+ }
314+ }
315+
316+ if ( $ result ) {
317+ break ;
318+ }
319+ }
320+
321+ return $ result ? '1 ' : '0 ' ;
322+ }
323+
242324}
243325
244326function gw_cl_entry_meta () {
0 commit comments