-
Notifications
You must be signed in to change notification settings - Fork 92
gpls-limit-by-paid-entries-only.php: Added new snippet for limiting by paid entries only.
#1186
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
Conversation
… by paid entries only
WalkthroughA new PHP hook file for Gravity Perks: Limit Submissions is added. The hook intercepts queries before execution, applies a form-specific filter for Form ID 123, and appends WHERE clause logic to count only paid or unset payment statuses. A static cache prevents reprocessing the same rule instance. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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 |
… by paid entries only.
gpls-limit-by-paid-entries-only.php: Added new snippet for limiting by paid entries onlygpls-limit-by-paid-entries-only.php: Added new snippet for limiting by paid entries only.
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: 0
🧹 Nitpick comments (1)
gp-limit-submissions/gpls-limit-by-paid-entries-only.php (1)
24-24: No changes required; code is correct as-is.The payment status value
'Paid'with capital P is correct per Gravity Forms documentation which lists "Paid" as a valid entry payment status. The logic correctly includes NULL and empty statuses to support forms without payment fields while filtering out failed/pending entries. This pattern is consistent throughout the codebase.The WHERE clause array approach matches the established pattern used elsewhere in the repository (e.g.,
gravity-forms/gw-inventory.php).Optional: Consider adding an inline comment for clarity:
+ // Include NULL/empty to allow forms without payment fields while excluding Failed/Pending statuses $ruletest->where[] = "( e.payment_status = 'Paid' OR e.payment_status IS NULL OR e.payment_status = '' )";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
gp-limit-submissions/gpls-limit-by-paid-entries-only.php(1 hunks)
🔇 Additional comments (4)
gp-limit-submissions/gpls-limit-by-paid-entries-only.php (4)
1-7: LGTM! Clear documentation.The documentation clearly explains the snippet's purpose and use case.
10-15: Excellent form filtering implementation.The logic correctly handles both targeted filtering (specific form IDs) and universal application (empty array), with proper type safety using
intvaland strict comparison.
17-22: Good use of static caching to prevent reprocessing.Using
spl_object_hashwith a static cache is an appropriate pattern to ensure each rule instance is only processed once per request.
26-26: Caching pattern correctly completed.The processed flag is set after the WHERE clause modification, completing the static cache pattern.
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.
LGTM!
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/3130050786/92261?viewId=3808239
Summary
Added a new snippet that filters GPLS to count only entries with payment status Paid. This prevents failed or pending payments from blocking resubmissions while still enforcing limits after a successful payment.