Skip to content

Conversation

@SebastianWiz
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/3167534483/95055?viewId=3808239

Summary

This PR extends the functionality of the Conditional Logic: Entry Meta snippet to support GPEV metadata. It allows users to create conditional logic rules based on whether an email address is identified as Free or Disposable by the validator service.

@coderabbitai
Copy link

coderabbitai bot commented Dec 12, 2025

Walkthrough

Modified conditional logic handling to support email-validator integration. Added optional form_id parameter to get_conditional_logic_options(), extended it to include email-validator conditional logic options for GF email fields, updated set_rule_source_value() to route email-validator targets through a new helper method, and introduced get_email_validator_result_value() to resolve email-validator derived values from entry metadata.

Changes

Cohort / File(s) Summary
Email-validator conditional logic support
gravity-forms/gw-conditional-logic-entry-meta.php
Added optional form_id parameter to get_conditional_logic_options() and adjusted admin scoping logic. Extended method to conditionally include email-validator options when gp_email_validator is available. Updated set_rule_source_value() to pass form ID and handle gpev_is_* targets via new helper. Added get_email_validator_result_value() method to inspect per-service validation results in entry meta and resolve Yes/No values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Method signature change with optional parameter affecting call sites
  • New email-validator integration requiring understanding of gp_email_validator structure and entry metadata handling
  • Multi-service validation result resolution logic with fallback metadata key handling
  • Single-file change but interconnected logic across multiple methods

Suggested reviewers

  • saifsultanc

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: adding support for GP Email Validator metadata (free, disposable) to the Conditional Logic Entry Meta functionality.
Description check ✅ Passed The description includes a Context section with a ticket link and a Summary section explaining the new functionality, matching the template structure.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch seb/add/95055-conditional-logic-gpev-metadata

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

Warnings
⚠️ When ready, don't forget to request reviews on this pull request from your fellow wizards.

Generated by 🚫 dangerJS against 2e8955c

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
gravity-forms/gw-conditional-logic-entry-meta.php (1)

287-287: Consider making the services array filterable.

The hardcoded services list may become outdated if GP Email Validator adds new validation services in the future.

Apply this diff to make it extensible:

-		$services = array( 'basic', 'kickbox', 'zerobounce' );
+		$services = apply_filters( 'gwclem_email_validator_services', array( 'basic', 'kickbox', 'zerobounce' ), $entry, $target );
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5b156c and 2e8955c.

📒 Files selected for processing (1)
  • gravity-forms/gw-conditional-logic-entry-meta.php (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-04-17T02:43:14.227Z
Learnt from: saifsultanc
Repo: gravitywiz/snippet-library PR: 1079
File: gp-populate-anything/gppa-acf-repeater-mapper.php:78-87
Timestamp: 2025-04-17T02:43:14.227Z
Learning: When working with Gravity Forms, `rgar()` is a utility function that safely retrieves values from arrays and can be used to implement cleaner safety checks compared to direct conditionals.

Applied to files:

  • gravity-forms/gw-conditional-logic-entry-meta.php
🔇 Additional comments (5)
gravity-forms/gw-conditional-logic-entry-meta.php (5)

86-88: LGTM!

The optional parameter addition is backward compatible and enables explicit form context passing.


91-91: LGTM!

Correctly prevents auto-scoping when an explicit form ID is provided.


232-232: LGTM!

Correctly passes the form ID to maintain proper context for the conditional logic options.


242-246: LGTM!

The routing logic correctly distinguishes between email validator targets and standard entry meta, with proper fallback handling.


279-322: Verify metadata key names and function availability.

Ensure that:

  1. The gform_get_meta() function is available in Gravity Forms 2.6.2+
  2. The metadata key names (free, is_free_email, free_email, disposable, is_disposable, sub_status) are correct for each validation service (basic, kickbox, zerobounce)

Run the following script to search for gform_get_meta usage in the codebase and verify it's a standard GF function:

#!/bin/bash
# Description: Verify gform_get_meta function usage and availability

# Search for gform_get_meta usage patterns in the codebase
rg -nC3 'gform_get_meta' --type=php

Additionally, please verify the metadata key names against the GP Email Validator documentation or codebase to ensure they match what each service actually stores.

Comment on lines +133 to +163
if ( function_exists( 'gp_email_validator' ) ) {
$email_fields = GFAPI::get_fields_by_type( $form, 'email' );
foreach ( $email_fields as $field ) {
if ( gp_email_validator()->is_email_validator_field( $field ) ) {
$props = array(
'free' => esc_html__( 'Is Free Email', 'gravityforms' ),
'disposable' => esc_html__( 'Is Disposable Email', 'gravityforms' ),
);
foreach ( $props as $prop => $label ) {
$options[ "gpev_is_{$prop}_{$field->id}" ] = array(
'label' => sprintf( '%s (%s)', $field->label, $label ),
'value' => "gpev_is_{$prop}_{$field->id}",
'operators' => array(
'is' => 'is',
'isnot' => 'isNot',
),
'choices' => array(
array(
'text' => esc_html__( 'Yes', 'gravityforms' ),
'value' => '1',
),
array(
'text' => esc_html__( 'No', 'gravityforms' ),
'value' => '0',
),
),
);
}
}
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Move GPEV integration inside the if ( $form ) block.

The email validator integration code uses $form but is placed outside the if ( $form ) block (which ends at line 131). This will cause errors when $form is null or false.

Apply this diff to fix the scope issue:

 			$form = GFAPI::get_form( is_array( $form_ids ) ? $form_ids[0] : $form_ids );
 			if ( $form ) {
 				$fields = GFAPI::get_fields_by_type( $form, array_keys( $post_submission_conditional_logic_field_types ) );
 				foreach ( $fields as $field ) {
 					$options[ $field->id ] = array(
 						'label'     => $field->label,
 						'value'     => $field->id,
 						'operators' => rgars( $post_submission_conditional_logic_field_types, $field->type . '/operators', array() ),
 					);
 				}
-			}
-
-			if ( function_exists( 'gp_email_validator' ) ) {
-				$email_fields = GFAPI::get_fields_by_type( $form, 'email' );
-				foreach ( $email_fields as $field ) {
-					if ( gp_email_validator()->is_email_validator_field( $field ) ) {
-						$props = array(
-							'free'       => esc_html__( 'Is Free Email', 'gravityforms' ),
-							'disposable' => esc_html__( 'Is Disposable Email', 'gravityforms' ),
-						);
-						foreach ( $props as $prop => $label ) {
-							$options[ "gpev_is_{$prop}_{$field->id}" ] = array(
-								'label'     => sprintf( '%s (%s)', $field->label, $label ),
-								'value'     => "gpev_is_{$prop}_{$field->id}",
-								'operators' => array(
-									'is'    => 'is',
-									'isnot' => 'isNot',
-								),
-								'choices'   => array(
-									array(
-										'text'  => esc_html__( 'Yes', 'gravityforms' ),
-										'value' => '1',
-									),
-									array(
-										'text'  => esc_html__( 'No', 'gravityforms' ),
-										'value' => '0',
-									),
-								),
-							);
-						}
-					}
-				}
+
+				if ( function_exists( 'gp_email_validator' ) ) {
+					$email_fields = GFAPI::get_fields_by_type( $form, 'email' );
+					foreach ( $email_fields as $field ) {
+						if ( gp_email_validator()->is_email_validator_field( $field ) ) {
+							$props = array(
+								'free'       => esc_html__( 'Is Free Email', 'gravityforms' ),
+								'disposable' => esc_html__( 'Is Disposable Email', 'gravityforms' ),
+							);
+							foreach ( $props as $prop => $label ) {
+								$options[ "gpev_is_{$prop}_{$field->id}" ] = array(
+									'label'     => sprintf( '%s (%s)', $field->label, $label ),
+									'value'     => "gpev_is_{$prop}_{$field->id}",
+									'operators' => array(
+										'is'    => 'is',
+										'isnot' => 'isNot',
+									),
+									'choices'   => array(
+										array(
+											'text'  => esc_html__( 'Yes', 'gravityforms' ),
+											'value' => '1',
+										),
+										array(
+											'text'  => esc_html__( 'No', 'gravityforms' ),
+											'value' => '0',
+										),
+									),
+								);
+							}
+						}
+					}
+				}
 			}
 		}

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In gravity-forms/gw-conditional-logic-entry-meta.php around lines 133 to 163,
the GPEV (gp_email_validator) integration block references $form but currently
sits outside the surrounding if ( $form ) conditional, which can cause errors
when $form is null; move the entire gp_email_validator() integration block so it
is inside the existing if ( $form ) { ... } scope (i.e., place lines 133–163
within that if block), preserving all existing logic/indentation and ensuring it
only runs when $form is truthy.

Copy link
Contributor

@saifsultanc saifsultanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@SebastianWiz SebastianWiz merged commit 1eb1e36 into master Dec 13, 2025
4 checks passed
@SebastianWiz SebastianWiz deleted the seb/add/95055-conditional-logic-gpev-metadata branch December 13, 2025 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants