From 71f6965f6fc5561b2358a95fb4532a7a3536e0dd Mon Sep 17 00:00:00 2001 From: SebastianWiz <165194375+SebastianWiz@users.noreply.github.com> Date: Tue, 21 Oct 2025 11:13:17 -0700 Subject: [PATCH 1/2] `gpls-skip-limit-if-blank.php`: Added new snippet for skipping limit if any Field Value is blank. --- .../gpls-skip-limit-if-blank.php | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 gp-limit-submissions/gpls-skip-limit-if-blank.php diff --git a/gp-limit-submissions/gpls-skip-limit-if-blank.php b/gp-limit-submissions/gpls-skip-limit-if-blank.php new file mode 100644 index 000000000..510085f23 --- /dev/null +++ b/gp-limit-submissions/gpls-skip-limit-if-blank.php @@ -0,0 +1,67 @@ +rules ) || empty( $rule_test->rule_group ) ) { + return $should_apply; + } + + // Replace '123' with your Form ID + $target_form_ids = array( 123 ); + + if ( ! in_array( (int) $form_id, $target_form_ids, true ) ) { + return $should_apply; + } + + $feed_id = method_exists( $rule_test->rule_group, 'get_feed_id' ) ? $rule_test->rule_group->get_feed_id() : null; + + if ( $feed_id && isset( $skip_feed_ids[ $feed_id ] ) ) { + return false; + } + + foreach ( $rule_test->rules as $rule ) { + if ( ! $rule instanceof GPLS_Rule_Field ) { + continue; + } + + $value = $rule->get_limit_field_value( $rule->get_field() ); + + if ( false === $value ) { + continue; + } + + if ( is_array( $value ) ) { + $value = GFCommon::trim_deep( $value ); + + if ( GFCommon::is_empty_array( $value ) ) { + if ( $feed_id ) { + $skip_feed_ids[ $feed_id ] = true; + } + return false; + } + + continue; + } + + if ( is_string( $value ) ) { + $value = trim( $value ); + } + + if ( rgblank( $value ) ) { + if ( $feed_id ) { + $skip_feed_ids[ $feed_id ] = true; + } + return false; + } + } + + return $should_apply; +}, 20, 3 ); From 4262f449b869e991a7df22e6a89c323e9dbe5cb4 Mon Sep 17 00:00:00 2001 From: SebastianWiz <165194375+SebastianWiz@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:15:21 -0700 Subject: [PATCH 2/2] `gpls-skip-limit-if-blank.php`: Added new snippet for skipping limit if any Field Value is blank. --- gp-limit-submissions/gpls-skip-limit-if-blank.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/gp-limit-submissions/gpls-skip-limit-if-blank.php b/gp-limit-submissions/gpls-skip-limit-if-blank.php index 510085f23..edc621d4d 100644 --- a/gp-limit-submissions/gpls-skip-limit-if-blank.php +++ b/gp-limit-submissions/gpls-skip-limit-if-blank.php @@ -8,8 +8,6 @@ */ add_filter( 'gpls_should_apply_rules', function( $should_apply, $form_id, $rule_test ) { - static $skip_feed_ids = array(); - if ( ! $should_apply || empty( $rule_test->rules ) || empty( $rule_test->rule_group ) ) { return $should_apply; } @@ -23,7 +21,7 @@ $feed_id = method_exists( $rule_test->rule_group, 'get_feed_id' ) ? $rule_test->rule_group->get_feed_id() : null; - if ( $feed_id && isset( $skip_feed_ids[ $feed_id ] ) ) { + if ( $feed_id && ! empty( $rule_test->skip_limit_feed_on_blank ) ) { return false; } @@ -42,9 +40,7 @@ $value = GFCommon::trim_deep( $value ); if ( GFCommon::is_empty_array( $value ) ) { - if ( $feed_id ) { - $skip_feed_ids[ $feed_id ] = true; - } + $rule_test->skip_limit_feed_on_blank = true; return false; } @@ -56,9 +52,7 @@ } if ( rgblank( $value ) ) { - if ( $feed_id ) { - $skip_feed_ids[ $feed_id ] = true; - } + $rule_test->skip_limit_feed_on_blank = true; return false; } }