Skip to content

Commit e502a8c

Browse files
authored
gpls-limit-by-paid-entries-only.php: Added new snippet for limiting by paid entries only.
1 parent 3324f97 commit e502a8c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Limit Submissions // Limit by Paid Entries Only
4+
* https://gravitywiz.com/documentation/gravity-forms-limit-submissions
5+
*
6+
* Only count entries with a Paid payment status when enforcing Limit Submissions rules so users with failed payments can submit again.
7+
*/
8+
add_action( 'gpls_before_query', function ( $ruletest ) {
9+
10+
// Replace '123' with your Form ID. Leave empty to apply to all forms.
11+
$form_ids = array( 123 );
12+
13+
if ( ! empty( $form_ids ) && ! in_array( (int) $ruletest->form_id, array_map( 'intval', $form_ids ), true ) ) {
14+
return;
15+
}
16+
17+
static $processed = array();
18+
$key = spl_object_hash( $ruletest );
19+
20+
if ( isset( $processed[ $key ] ) ) {
21+
return;
22+
}
23+
24+
$ruletest->where[] = "( e.payment_status = 'Paid' OR e.payment_status IS NULL OR e.payment_status = '' )";
25+
26+
$processed[ $key ] = true;
27+
} );

0 commit comments

Comments
 (0)