This snippet allows you to limit submissions to any (or all) Gravity Forms per a time period (i.e. 30 minutes, 24 hours, 2 days, etc) by a WP User ID, by the submitting users IP adddress, or from a specific embed URL.
This snippet replaces both the Limit User to One Submission Per Time Period and the Limit IP to One Submission Per Time Period snippets.
This snippet was updated on January 15th, 2012 to provide support for limiting by the embed URL of the form and also specifying multiple “limit_by” parameters. Big thanks to Lee for funding this enhancement!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
How do I install this snippet?
Easy peasy. Just copy and paste the code above into your theme's functions.php file.
How to I use this functionality?
All you need to do is create a new instance of the GWSubmissionLimit()
class, populated with your specific details, like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Want to apply the same submission limit to all forms?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Want to apply multiple limitations? This example allows you to limit the number of a submissions a logged in user can make to specific form from the same embed URL. This would allow you embed the same form on multiple pages and allow users to submit that form up to the submission limit on each page.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Here is a full list of available options:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
form_id
The form ID of the form you would like to limit. If you want to apply the the same submission limit to all forms, set theform_id
asfalse
or do not provide it at all.limit
The number of submissions allowed before the user will no longer be able to make additional submission.time_period
The period of time to which thelimit
applies. The default time period is one day. In any 24 hour period, if the user reaches thelimit
they will no longer be able to make new submissions.limit_message
The message which should be displayed to the user once they have reached the specified submission limit.limit_by
Specify which identifying data the user should be limited by. The default isip
.user_id
is also supported which allows you to limit logged in WP users.embed_url
is now supported to limit submissions of a form from a specific embed URL.