-
Notifications
You must be signed in to change notification settings - Fork 92
gw-conditional-logic-entry-meta.php: Added support for GP Email Validator metadata (free, disposable).
#1196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gw-conditional-logic-entry-meta.php: Added support for GP Email Validator metadata (free, disposable).
#1196
Conversation
…idator metadata (free, disposable).
WalkthroughModified conditional logic handling to support email-validator integration. Added optional Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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
📒 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:
- The
gform_get_meta()function is available in Gravity Forms 2.6.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_metausage 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=phpAdditionally, please verify the metadata key names against the GP Email Validator documentation or codebase to ensure they match what each service actually stores.
| 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', | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
saifsultanc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
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.