Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions gp-limit-submissions/gpls-limit-by-paid-entries-only.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Gravity Perks // Limit Submissions // Limit by Paid Entries Only
* https://gravitywiz.com/documentation/gravity-forms-limit-submissions
*
* Only count entries with a Paid payment status when enforcing Limit Submissions rules so users with failed payments can submit again.
*/
add_action( 'gpls_before_query', function ( $ruletest ) {

// Replace '123' with your Form ID. Leave empty to apply to all forms.
$form_ids = array( 123 );

if ( ! empty( $form_ids ) && ! in_array( (int) $ruletest->form_id, array_map( 'intval', $form_ids ), true ) ) {
return;
}

static $processed = array();
$key = spl_object_hash( $ruletest );

if ( isset( $processed[ $key ] ) ) {
return;
}

$ruletest->where[] = "( e.payment_status = 'Paid' OR e.payment_status IS NULL OR e.payment_status = '' )";

$processed[ $key ] = true;
} );