Better Limit Submission Per Time Period by User or IP
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 user ID, user role, IP address, a specific form URL, or the value of a specific field.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
November 10, 2018: Updated to work with Gravity Forms 2.3+. Special thanks to Daniel Kelly.
Stop! There's a better way.
This snippet is available as a plugin with Gravity Perks, a suite of over 46 premium Gravity Forms plugins!
This snippet replaces both the old Limit User to One Submission Per Time Period and the Limit IP to One Submission Per Time Period snippets.
How do I get started?
- Gravity Forms v1.8 is required to use this snippet.
- Already have a license? Download Latest Gravity Forms
- Need a license? Buy Gravity Forms
- Copy and paste the snippet into your theme’s functions.php file.
- Modify the “Configuration” portion of the snippet (at the very bottom of the code) to meet your needs. Full usage instructions are below.
Usage
Basic Usage
Apply a submission limit per 24 hour period (default time period) to a specific form.
new GW_Submission_Limit( array(
'form_id' => 86,
'limit' => 2,
) );
Apply to ALL Forms
Apply a submission limit per 24 hours period to ALL forms.
new GW_Submission_Limit( array(
'limit' => 5
) );
Multiple Limiters
Limit the number of a submissions a logged in user can make to specific form from the same embed URL. This would allow you to embed the same form on multiple pages and allow users to submit that form up to the submission limit on each page.
new GW_Submission_Limit( array(
'form_id' => 2,
'limit' => 1,
'limit_message' => 'Aha! You have been limited.',
'limit_by' => array( 'embed_url', 'user_id' )
) );
Limit by Role
Limit by the logged in user’s role. The limit
parameter must be specified as an associative array with the role name as the key and the limit as the value.
new GW_Submission_Limit( array(
'form_id' => 2,
'limit_by' => 'role',
// when "limit_by" is set to "role", "limit" must be provided as array with roles and their corresponding limits
'limit' => array(
'administrator' => 20,
'contributor' => 5
)
) );
Limit by Calendar Time Period
Limit by a calendar time period (i.e. “day”, “month”, “year”). This means that if you set a limit of “5” and the user reaches the limit on December 31st, they would be able to create five new submissions on January 1st. If you set the limit to a month in seconds (i.e. “2678400”, 31 days in seconds) and the user reached their limit on December 31st, they would not be eligible to create another submission until one of their previous submissions expired from the month-long time frame.
new GW_Submission_Limit( array(
'form_id' => 3,
'time_period' => 'per_month'
) );
Limit by Field Value (with no time period)
Limit by the value of a specific field. This is similar to Gravity Forms “No Duplicates” functionality except you can specify how many “duplicates” are allowed and can use other limiters (i.e. allowing no duplicates per user and more). Also demonstrated is the false
value for the time_period
parameter which results in the limit applying forever.
new GW_Submission_Limit( array(
'form_id' => 1,
'limit_by' => 'field_value',
'limit' => array(
// "2" is your field ID, "6" is your limit for this field ID
2 => 6
),
'time_period' => false // forever!
) );
Parameters
form_ids
The form ID(s) of the form(s) you would like to limit. If you want to apply the the same submission limit to all forms, set the
form_id
asfalse
or do not include this parameter at all. If you would like to limit multiple forms, pass the value as an array of form IDs.limit
The number of submissions allowed before the user will no longer be able to make additional submission. If limiting by
role
, the limit should be an array oftime_period
The period of time to which the
limit
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.If you want to limit by less than a day, you can provide the time period in seconds. A time period of
60
would be one minute (60 seconds). A time period of60 * 60
(or3600
) would be one hour.Also supported are three different calendar periods:
per_day
,per_month
,per_year
. Calendar time periods are more rigid time periods that “reset” when the calendar time period expires (i.e. one month ends and another begins).If you do not want to limit by a time period at all, set the time period to
false
.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. Supported values:
ip
: limit by the visitor’s IP addressuser_id
: limit by the logged in user’s WordPress user IDembed_url
: limit submissions of a form from a specific embed URLrole
: limit by logged in users role (i.e. “administrator”, “contributor”)field_value
: limit by the value entered into a specific field; works similarly to Gravity Forms’ default “No Duplicates” option, except you can specify how many times the value can be duplicated.
Is there a way to provide a custom message to let the user know why they cannot submit? In my case, we are checking address. We’d like to clearly let the user know that a submission with this address was already submitted/sent?
Maybe it already does this, but I’m not seeing anything mentioned.
Hi Frank,
The configuration for this snippet accepts a limit_message parameter, which you can use to set a custom message to display when the limit is reached. Please check the documentation above for more details on this. However, if this isn’t what you want, then you may want to check out our GP Limit Submissions Perk, which has a more user-friendly way of setting a custom message.
Best,
Hi, is it possible to limit_by both by IP and field_value? If so what would the limit array look like in that case?
Hi Aaron,
Something like this should do the trick:
new GW_Submission_Limit( array( 'form_id' => 2, 'limit' => array( // "2" is your field ID, "6" is your limit for this field ID 2 => 6 ), 'limit_message' => 'Aha! You have been limited.', 'limit_by' => array( 'ip', 'field_value' ) ) );
Is there a way to allow users to “buy” more submission limit sold as a woocommerce product, and update the user’s limit amount?
Hi Claudio,
This isn’t currently supported with the snippet or with the perk version of this. I will add this to our list of feature requests for the perk.
Hey there, this was working perfectly but now it isn’t, I’m not sure if its an update for Gravity Forms that has broken it?
We were limiting by user_id and now it’s not working for people logged in via MemberPress?
Any ideas?
Using 3.0 of the script,
Configuration
new GW_Submission_Limit( array( ‘form_id’ => 17, ‘limit’ => 1, ‘limit_by’ => ‘user_id’, ‘limit_message’ => ‘
You have already requested a copy of the handbook.Once you\’ve had a chance to read the book it would be great if you could leave us a review on Amazon too!
‘ ) );
Hi Chris,
It still is working for me when I test locally. I suspect there might be something else at play, such as a plugin conflict.
If you have a Gravity Perks subscription, we suggest using the Perk version of this, as it is more up-to-date, doesn’t require manual configuration, and includes support.
Hi! i’ve tried installing the perks, per IP for only 1 submission per 24 hours. so do i set the submission limit to only 1 or? because if i were to set the submission limit to only 1, then other people who logged on to that form are unable to submit the form?
appriciate if you could assist?
thanks
Hi,
I have sent you a reply via email so we can request more information about the issue you’re experiencing. Please check and reply via email.
Best,
Hey guys, thanks for the great snippet.
I have two questions.
Would it be possible to apply this to all forms except predefined ones? As far as I understand it currently we can limit to “all forms” or “specific ones”, but not “all except for…”.
Additionally I would like to use it with gf polls addon, which works fine. Only thing is that I don’t want to disable the form altogether but rather display the form but have the submit button disabled. Reason for this is that users should still be able to see the results of the poll which they can on the form by hitting the “see results” link. Even better of course would be to simply show the results of the poll if limit has been reached.
Cheers
Joe
Hi Joe,
Both your requests will require some customization to the snippet and snippet customization is only available to our Pro Customers. So if you have an active Gravity Perks Pro license, you can get in touch via our support form so we can get our developers to look into your requests. Regarding your second request, we actually already have a snippet that works together with our GP Limit Submissions Perk, to show the Poll results if the limit has been reached.
Best,
Can this be used inside of a hook where I can set the gravity form id dynamically from the backend and have this code be called, for example in the ‘init’ hook, but where I can obtain the gravity form id from, instead of putting directly in functions.php? Can you maybe suggest a hook for this?
Hi Solomon,
You should be able to set different feeds without a single line of code per form using our GP Limit Submissions perk.
Best,
My table has two input fields. Suppose I have entered the ID in the first field, and when I enter the same value in the second field, do I have a way to judge before submitting
Hi Lemon,
We already followed up on this via email, but I wanted to post this in the comment thread so other customers could see it.
From what I understand this tutorial to prevent duplicate values in the same form should work: https://gravitywiz.com/gravity-forms-require-unique-values-for-different-fields/
Best,
Can anyone confirm this still works with Gravity Forms 2.5.X?
Hi Jon,
Yes, the snippet works with Gravity Forms 2.5.x.
Best,
Hi, can some one help me to change code to get unlimited number of submissions using “-1” value in “by role” mode?
Hi Luigi,
To set an unlimited number of submissions, you should set the time_period parameter to false
'time_period' => false
.new GW_Submission_Limit( array( 'form_id' => 2, 'limit_by' => 'role', // when "limit_by" is set to "role", "limit" must be provided as array with roles and their corresponding limits 'limit' => array( 'administrator' => 20, 'contributor' => 5 ), 'time_period' => false // forever ) );
I am trying to use this to limit a drop-down to the number of times a value can be selected.
Beginner 4:30pm – 5:15pm 5 times Beginner 5:30pm – 6:15pm 10 times Beginner 6:30pm – 7:15pm 3 times
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘field_value’, ‘limit’ => array( ’18 & up 1:00pm – 2:00pm’ => 2 ), ‘time_period’ => false // forever! ) );
I am sure I am understanding the wrong could you clarify.
Thank you.
Hi Kiel,
This plugin limits by unique field values. It isn’t capable of setting different limits for the different choices. This is a great fit for Limit Choices.
Hello,
I want users to do a quiz where they have to reach 70% good answers. They will get two retakes to get to this percentage.
How can I limit the times they can submit the quiz?
I thought limit them on the email field, because that is an unique value, but when I do this I get an error with the code you provided.
http://snippi.com/s/qzg6l7g
What am I missing?
Hello, Are you attempting to have the quiz only be limited two times in total or do you want the user to get two chances only if they get 70% or higher? Let us know your intent so we could guide you correctly on this one. Best!
Hi there, I’m looking to limit the same form entries per user per month. So user1 and user2 have 10 separate entries per month. I tried the following snippet but I’m getting an error. I have the <?php opening and closing tags removed because it’s already there in the file. Please advise.
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘user_id’, ‘time_period’ => ‘per_month’ ) );
Hi Julie,
The snippet appears to be working correctly when I tested it on my end. Please refer to our article on snippet troubleshooting for details on installing our snippets.
That said, bellow is the configuration I used on my end, you could copy and paste it and see if it works for you too.
new GW_Submission_Limit( array( 'form_id' => 1, 'limit_by' => 'user_id', 'limit' => 10, 'time_period' => 'per_month' ) );
Hi there, I’ve used the following however, the limit message doesn’t work. Please advise. Thank you.
new GW_Submission_Limit( array( ‘limit_by’ => ‘user_id’, ‘time_period’ => ‘per_day’, ‘limit_by’ => ‘role’, ‘limit’ => array( ‘um_wilson’ => 3, ‘um_dundas’ => 4, ‘limit_message’ => ‘You have reached the maximum # for the day.’ ) ) );
Hi Julie,
You have the limit_by parameter set to both user_id and role which, shouldn’t be so. Either you set the limit_by parameter to user_id and assign an integer to the limit parameter or you’ll set the limit_by parameter to role and set the limit parameter to an array of roles and their limits. Also, I see that you didn’t pass a form ID parameter, so I am guessing this snippet is going to apply to all the forms on the website. In case you want to set the limit for a particular form by role, the snippet configuration will be similar to this;
new GW_Submission_Limit( array( 'form_id' => 2, // Update 2 to the Form ID 'time_period' => 'per_day', 'limit_by' => 'role', 'limit' => array( 'um_wilson' => 3, 'um_dundas' => 4, 'limit_message' => 'You have reached the maximum # for the day.' ) ) );
If I want my merge mark to be allowed only once, what should I do
Hello. could you please let us know some more information as to what you are attempting to do? We would be more than happy to help!
Hi there,
I’m trying to create a form whereby a user rates an instructor, from a dropdown menu. I would only like a specific user id to rate each instructor once every 3 months. How would I go about inputing these values?
Hi Faiz,
If I understand your question correctly, you want only one user to be able to submit the form once in 3 months. If that is correct, then first of all you can use GP populate Anything to populate a hidden single-line text field on the form with current user Id. Then using the current User ID, you’ll set up conditional logic on the form button to only show if the current User Id matches the specific User ID.
The next thing will be to use GP Limit Submission Perk, to limit submissions to the form to once every 3 months using the Time Period. Unfortunately, it’s not possible to use the Snippet above to set the limits to a time period of 3 months, but the GP Limit Submissions Perks offers you that option.
If this doesn’t work for you and you’re a Gravity Perks license holder, you can send us a message via our support form with an export of your form so we can assist you further.
Best,
I am running into WP Supercache issues. It seems as if the limit_message is getting cached. So when I test the form, the cached message with no form is being displayed to all visitors.
Any idea how to not cache the limit message page?
Hi Adam,
This is an issue with WP Super Cache. The solution will be to either adjust the exclusion rule of the plugin, so it doesn’t cache the pages with Gravity forms or you’ll have to use another caching plugin.
Best,
HI, we are experiencing users donating via the Gravity form then the transaction being repeated hours or days later. GForms support has concluded these were from mobile devices which save the browser tabs and reload them when you open the browser possibly causing the submission to be sent again for a new donation.
They have suggested limiting the form, but I just wanted to check to see if there was a limit set to 1, would they not be able to donate again ever? How can you determine it is a repeat of the initial form or a new donation?
Thanks for any help.
Hi Craig,
If the
time_period
parameter isn’t set, they will be limited to 1 submission per 24 hours. If you want to shorten or lengthen that time, simply set thetime_period
you want to limit on.Thanks for your response. So if they open their phone and their browser a day later and have not closed out that tab, it could potentially resubmit that entry again then? But if I limit them by email or for a longer period, they cannot donate more than once, which is not realistic. Ideally the form would disable itself once sent and force a new form with everything cleared from the fields if reloaded.
Hey Craig, depending on the limit, it should not allow the user to submit the entry again until the 24 hour period is over due to the limitation. A possible way you can get around this would be to add a confirmation to your form. That way the user would be brought to a confirmation page and not be able to resubmit the form.
Hello, with your extension it is possible to limit access according to the IP of the device (but not of the network) and the value of a specific field e.g. hotel rooms?
I’m trying to do this:
a menu questionnaire for hotel guests, but I would like customers (many of whom are connected to the wifi network) to be able to send the menu choice only once (because the menu changes every day) and to send it only once per room , in order not to create double menus.
recapitulating my questions are 2:
1) Is it possible to limit access ID, only of the device, but not of the network? 2) it is possible to allow only the insertion of one room at a time, e.g. room 101? and don’t allow the same number to be entered again?
Hello Tobi, thanks for reaching out. 1) the limit will be set by the network as this is how the WordPress system picks up the IP address. Due to this being a built-in function, unfortunately, we cannot change that one. 2)Will this be a dropdown/choice field or a user-defined field? Thanks!
Thanks for the reply
1) is there a solution for this wordpress limit? 2) it will be a number field, where the customer will manually enter the room number (example 101)
Hi Tobi,
1) The IP address that WordPress (or any site) sees is the public WAN IP. It isn’t possible to for it to resolve an individual device’s IP on a network. One solution that could work here is to require the guests to have an account and be signed in to fill out the form. You can then use Limit Submissions to limit each user to once per day.
2) Limiting based on a Number field will work great. Simply add it to the Rule Groups, choose Field Value, and then choose your Number field from the Drop Down.
thanks again for the availability
1) it was a bit what I wanted to avoid, having to register them or communicate credentials for access.
2) so I can Select in the rules: field type> reference field> space to enter the number of rooms?
Hey Tobi, 1)I see. Sadly we do not have a direct solution for this one. 2) You would use a field value: field_value: limit by the value entered into a specific field; works similarly to Gravity Forms’ default “No Duplicates” option, except you can specify how many times the value can be duplicated. It would work much like the example above for Limit by Field Value. If you currently have our Gravity Forms Limit Submissions perk, and are a Gravity Perks license holder, you can reach out to us through our support channel and we can take a closer look into this for you.
Hi,
A quick question on this… I’m trying to get it to limit submissions from non-signed in users – is that possible? Basically I have the form on one page, but want to prevent a user with the same email address entering the same answer again in one field. I’ve tried the below but it doesn’t work… any idea?
Thanks, Matt
Basic Usage
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘field_value’, ‘limit’ => array( // “2” is your field ID, “6” is your limit for this field ID 10 => 1, 4 => 1 ), ‘time_period’ => false, // forever! ‘limit_message’ => ‘Sorry, you have already entered for this experience!’ ) );
Hey Matt, this would require us to take a deeper look into the form to solve. Do you have two fields you are trying to use this with? I see you want to validate both fields 10 and 4? This A better solution would be to use the Gravity Forms Limit Submission Perk. If you already have a Gravity Wiz Perk License, go ahead and reach out to our support with your form and we would be more than happy to take a deeper dive.
Thanks Ryan – I wasn’t sure if the plugin allowed you to do so without being a logged in user…
Basically, field 10 is automatically populated with an ID (depending which page you come to the form from), and I don’t want the same person to be able to enter twice with the same email (field 4) on the same ID…
Means I could probably limit it to one entry per email by entry_url as well, but still can’t work out how that works if not logged in?
Cheers, Matt
Thanks for the snippet. Can i exclude some ips? I am using as limi by ip. I want to limit only visitors not admin. Thanks again.
hello, I want to stop the submission of a form when the linked company’s server it sends info to is down for maintenance which is a 2 hr window on a Friday night each week. Would something like this work, I see Gravity forms have restrictions for certain hrs every day but I only want it every Friday for 2 hrs.
Hey Ed, This would be something that could be solved by one of our perk called Conditional Logic Dates. We actually have a tutorial on how to accomplish this found here. Thank you so much. 😃
Could this be used if you wanted to limit the number of times a box was checked by different users. Say there’s a checkbox that says “YES! I want the free gift!”, but you only have 30 units to give away. Could you you specify: ‘limit_by’ => ‘field_value’, ‘limit’ => array( // “25” is your field ID, “30” is your limit for this field ID 25 => 30 ), And once the 30th person who submits the form checks the box, he or she will get the limit message?
Hey Nathan, something like this would be better suited for this snippet. The best solution would be to use our Gravity Forms Limit Checkbox Perk. 😃
Thanks!! Much appreciated!
I am having trouble getting the limit by field value working, it seems to do nothing as far as I can tell, the duplicate submissions still go through.
I copied the code snip, and making sure to change the form ID and field ID inserted it into my functions.php file. If I change the limit_by to ‘ip’ instead of ‘field_value’ the limiter functions so I know I am targeting the form correctly.
The field_value being limited is the Name field in the form right below “Contact Paul Mones & Get Help Today” in the link below, also a snippi of the functions.php file is attached.
https://devmones.wpengine.com/ http://snippi.com/s/as48ukt
Any insight would be helpful, thank you.
Hello BV, This is an interesting question. Could you please try and replace your configuration file with this one http://snippi.com/s/lzynybd. This file will focus in on the First and Last Name fields through the ‘fields’ array. 😀 That should do the trick for you.
Thank you Ryan, that worked perfectly. I appreciate the quick response. Cheers!
Can this be modified to release the limit at a specific time of day rather than a time period?
Hello Cole, sadly we do not have a readily available solution for this one as the time is based on hourly interval ie 24 hours. Our Gravity Forms Limit Submissions plugin would give you a little more flexibility as in time period. If you like you could drop us a support request and we could take a closer look at your site. Thank you!
Thanks Ryan. My goal is to release voting limit at midnight regardless of whether a vote was cast at 12:01 am or 11:59pm. Is that something the plugin allows?
Hey Cole, With the GF Limit Submissions Perk you can actually set by day instead of hourly so this would cut off at the end of each day instead of 24 hours later. If you buy the perk know that we have a 30-Day 100% Money-Back Guarantee and we would be more than happy to answer any questions through support. 😀 Have a wonderful day!
Hey Ryan, I have purchased and installed the Perk. Here’s my goal, which I’m still very unclear if the Perk will resolve.
I will have a poll for best bartender in a group (http://ironbartender.org/test-page/). I want to limit votes per day. NOT 24 hours, but per calendar day. Ideally, I want the limit to be by a cookie so that it is individual based. Via IP will not work because there will be voters on the same networks, such as a home or a business. I do not want to require folks to log in.
So, I set up the Gravity Forms Poll add-on, which includes cookie restriction but only by 24 hour period. That is the problem here. I want to clear the cookie at midnight.
I had understood that the snippet I previously tested would allow time_period: per_day and that would solve the issue. However, it doesn’t seem to override the setting in the Poll add-on itself.
Is there a way to do this with the combo of the Gravity Poll add-on and GP Limit Submission Perk or snippet? Since I’m more designer than developer, this one is hurting my brain now.
Really great snippet, thanks for creating this.
Probably a weird question but is there a way of dynamically updating the limit, say for example if someone sent another form this would then increase the limit on the form the limit has originally been set on.
Thanks again.
Hello Jordan, Do you have another use case for this one? If the user attempts to submit another form, the form would get denied if within the time period. Are you wanting to allow more submissions during a specific time period or will there be a way for the user to override the limited submission? Let us know.😀
Sorry! That was poorly worded, my bad.
I think I’m actually barking up the wrong tree as well. I need to give a user the ability to send a form which initially only allows them to submit it once and then if the form submission is replied/interacted with on the recieving it removes the limit so they can then use the form again.
Hope this makes sense! And thanks in advance.
Hey Jordan, Thank you for that explanation. We do not have an automated way of doing this, but pretty much if you trash the entry that was submitted after replying or interacting with it, this will reset the limit. I hope that helps! 😁
how to show the limit remaining? say you limit 2 submissions per 24 hours, how to display the amount on the page saying 1 submission remaining, etc
Hi Chris, there is a shortcode to support this in the plugin version of this snippet.
Hello,
Is there any way to share the code instead of the plugin shortcode? I’m just using this snippet for coz I can’t afford to buy the plugin for now but I really need to display limit remaining to users so they can monitor how many submissions they can still submit.
Hi SeyntJim, we provide hundreds of free resources but in order to stay in business we do have to charge for some things. Hope you understand. 🙏
Thanks for this. With regard to limiting based on a field value, how does that work in relation to a radio button field? I have options for time slots, and I need to limit each time slot to 10 reservations.
Does your snippet for field value simply check if there is a value in that field / not empty when submitted?
Are radio buttons not selected considered empty fields? Thanks in advance for your help.
Hi Brian, this snippet (and the GP Limit Submission plugin) are not designed for inventory. If you want to do inventory, check out Gravity Forms Limit Choices for choice-based inventory and our Better Inventory snippet single Product inventory.
Hello David,
Thx a mil for all the Wizes!
Question: I’m running your Gravity Wiz // Gravity Forms // Automatic Save & Continue function within the Space X-Chimp plugin and would love to combine that with this one: Gravity Wiz // Gravity Forms // Limit Submissions Per Time Period (by IP, User, Role, Form URL, or Field Value).
But it returns this code: Sorry, but your code causes a “Fatal error”, so it is not applied! Please, check the code and try again.
Hi Ignatius, there is likely a rogue character in your PHP file. If you want to send your functions.php to me at david@gravitywiz.com, I’ll be happy to take a look. Please include a link to this message so your message is not auto-archived.
I have GF as a Voting form. I found with the Limit Submissions code, after a vote has been actions, the message comes up to says ‘Aha! You have been limited.
However if I refresh my browser, another vote is added. then a 3rd and 4th etc.
Is there a way to stop this?
Thanks
Dont worry. I just stopped using it. Fixed it.
Just checked the block repeat voters in Polls addon.
No need for this code any more
Roger that, Pete. For what’s it worth, I setup a demo to attempt to recreate this issue but was unable to do so.
how to disable or hide gravity forms all times . show at 10AM and hide 10:15AM . Similar to the Gravity Form settings section -Restrictions-Schedule form
Hi Ras, are you just looking to make the Form Schedule apply daily?
HI David, I want to make the online doctor appointment form… Just be open every day for a limited time.
Schedule form to be active/deactivate (open/close) on specific times (everyday)? what i would like to do is create a form that allows submissions on time X and stops allowing submissions on time Y and prior to time X it displays message A instead of the form and after time Y the page displays message B instead of the form .
Hi Ras, I found your StackOverflow question and answered there: https://stackoverflow.com/questions/58150431/how-to-show-hide-gravity-forms-at-preset-time/58160730#58160730
Hello I have one question I hope some one will help Here is my question I have created one coupon validator using gravity form and invitation addon. Link of addon https://codecanyon.net/item/gravity-forms-invitation-codes/11441758
Now i just want that 1.if user tries to enter wrong code 3 times display captcha. 2. on 4th attempt user enter correct code should see congratulation message.(that is already present) so how could i do that??
Live link https://loveorganics.in/demo/verify/
thank You in advance
You could certainly use this snippet as a basis for this functionality but it is not possible without further customization.
do you have any reference code or anything else so i can figure out how to do it??
or for functionality what i can put there? i tried bt not not getting what i want exact
Thank you for sharing this great resource.
I am having an issue though.
When I have the code live, the forms will just spin. I receive the submission but the user does not see the gravity forms confirmation.
What is causing the conflict?
Here is what I have –
http://snippi.com/s/4x3g71t
Also, am I able to put in multiple form ids? and have multiple limit options? You can see in the snippi link what I am trying to do.
Thank you, Tyler
Hi. Limit submission not work for edit entry in Gravity View. for example user limit to submit 10 submission and then can’t edit previous submission. is any solution for this problem.
Hi Mostafa, you would need to write a bit of custom code that checks if you’re loading the form in Gravity View’s edit more and then only initialize the snippet if you are not.
WIth that said, the plugin version of this snippet automatically handles this. Check it out! https://gravitywiz.com/documentation/gravity-forms-limit-submissions/
Hi David! i try gravity perks and Limit Submission for my Gravity Form but not work! my user after 10 submission cant edit previous entry. Can You explain some code or tricks for me? Thanks
Submit a support ticket and we’ll be happy to dig in. ?
Great snippet. What I need to do if I want to limit more than 1 field? I’ve tried to add input to an array, e.g. ‘limit’ => array(16 => 1, 12 => 1, 16 = > 1) But, it only applies the first, the other two seems not working. Maybe I did it wrong somewhere. Please help.
Hi Mijesh, here is how to do it: https://gravitywiz.com/documentation/apply-class-based-snippet-different-forms/
Is it possible to limit ip by a specific date? I dont want to hide the form on a date but the ip limit would stop on a specific date. For example, it I wanted to limit ip until April 13th at 11:59pm (so 12:00am on April 14th the limit is lifted) what would it be?
This is what I have –
Basic Usage
new GW_Submission_Limit( array( ‘form_id’ => 3, ‘limit’ => 1, ‘limit_by’ => ‘ip’, ‘limit_message’ => ‘You have reached the coupon download limit’, ‘time_period’ => ‘???’ ) );
Your best bet will be to simply wrap the whole initialization in a check. Something like…
if( time() >= strtotime( ‘April 13, 2019 11:59pm’ ) ) { // init code }
Quick question. I’m trying to use a single form that pulls in dynamic information. Right now I have the form setup to pull in a “value” from a post object to a hidden field on the form. The value will be a preset number of signups allowed.
Is there a way using this snippet that I can have the limit requirement pulled from this hidden field so no matter which post loads, the limit will always refer to this unique hidden value?
For the record, I’m pulling this information from a PODs Custom Post Type.
If you dynamically populate a field on the form with the unique value you can use the “field_values” limit type to limit by the value of this field.
Is there a way to limit it based on form submissions that cause an error? Basically, if a user fails to submit the form successfully after 5 times, I’d like to prevent them from seeing/submitting the form. Are there any plugins to handle that?
Hey Jon, we don’t have a solution for this one…
Hello, This is working great but, I need advise on one issue. How would I apply the limit_message to all forms, regardless of which one is filled.
For example, I have three forms and a user fills one of them out. Now I want all three forms that I specify in forms_ids array to receive the limit_message, because one of the three has been completed.
In other words, the limit message gets applied to all forms in the array, regardless of which form in the array is completed.
Thanks for your help!!!
Hi Frank, set the “apply_limit_per_form” as
false
to apply to all form IDs you’ve specified.if i have say 5 differen forms but i only want users to be able to submit 3 of them 1 time each, can this be done?
I think it could be accomplished if you create two instances. One so that each of the 5 forms can only be submitted once. And another rule so that the user has a total limit of 3.
And another rule so that the user has a total limit of 3. Not quite sure what you mean by this?
I currently have:
new GW_Submission_Limit( array( ‘limit’ => ‘3’, ‘limit_message’ => ‘Aha! You have been limited.’, ‘limit_by’ => ‘user_id’, ‘apply_limit_per_form’ => ‘false’, ) );
but this is limiting a user id to submit the same form 3 times. I need this to become global so that if they submit any 3 forms then try a 4th, they wont be able to. I thought the apply limit per form option would make this happen but it doesn’t seem to do anything.
Thanks
I’ve updated the code to work with GF 2.3.6. You can find the updated snippet here: https://github.com/danielkdesigner/gf-no-dupes
Thank you, Daniel! I’ve merged your changes with the core snippet and gave you a shoutout in the update notification at the top of the post. ?
Hi guys, great snippet, but as you pointed out to Nicolas on August 31, it does not yet work with the latest version of GF.
Could this be the cause of the issue I have with the ‘per_day’ limit combined with ‘by IP’? I have a campaign website with a form for free daily donations (sponsored by companies in our network), you can see it in action here: https://www.getuigengevraagd.nu/gratis-doneren/.
Some users have not submitted the form for months, but still get the message that they already donated today. But I can’t figure out why some users have this issue and other users can use the form daily without any problem.
Can you please help me to find the cause of the issue? If the plugin is up-to-date with the latest version of GF and this solves the issue, I’m ready to buy the plugin.
Hi Gert, GF 2.3 introduced some major database changes which is why the snippet no longer works. We do intend to update this snippet but we have hundreds of snippets that also need updates. If you need this functionality immediately, please check out the plugin version: https://gravitywiz.com/documentation/gravity-forms-limit-submissions/
Hi, how to ingrate this in wordpress? or is a part of add-on gravity form ?
This is a snippet that extends Gravity Forms.
Does it work with Gravity Forms 2.3?
Or now we have to buy the paid version?
Hi Nicolas, the snippet version has not been updated to work with 2.3 yet. The plugin version does work with 2.3.
Is there a way to set the ‘time_period’ to be set from 12:00am to 11:59pm? Instead of the current/default ‘per_day’? An example that I have and is a problem is if someone is voting, and they vote at 11:30am on Tuesday they currently have to wait till 11:30am Wednesday to vote again.
If you set it to 60 * 60 * 24 with a limit of 1, they will not able able to submit the form again until 24 hours from their last submission.
Ok, so there is NO way to have it set from Midnight to Midnight. It is just 24 hours from the time of their submission.
Sorry, I’m confused. per_day is from midnight to midnight. If you’re having issues and need support, I would first try GF Limit Submissions. If you still require support, we can help you here: https://gravitywiz.com/support/
I had a user complain to me that they could not vote when I had the ‘per_day’ set in the ‘time_period’. That is why I was asking if it was a 24 hour from the time of casting a vote.
Hi, your code is amazing.
How can I use that to limit a submission to one per logged in user? I do not know the user_id since it changes form user to user. Meaning a user creates an account gets directed to the form an the can submit only once. I would not like use the a field with “No duplicate” option since the user only enters their name and not e-mail address.
Is this possible with your code?
Hi Stephan, yup. Just set the limit_by to “user_id”. You don’t actually need to specify a specific user ID. It will simply limit each user (by their user ID) to whatever limit you specify (in this case, 1).
I have a pre-sale question on Gravity Forms Limit Submissions.
I have a form that is a test and the user can not click submit if they have answered a question wrong. I would like to limit the number of times a logged in user can attempt to pass the test. The form is a multi part form and the last page in the form shows if they passed and allows them to submit or it shows the user they failed the test and will not allow them to submit the form. Can I use this plugin to limit the number of attempts without them actually hitting submit button. can it be limited based on a form element even if it s not submted?
Hi Darin, sorry, GP Limit Submissions only works for limiting on successfully submitted entries.
Thanks David, but it looks like from this comment that the Gravity Perks version is in a queue to be updated also, or did I misunderstand the note? https://gravitywiz.com/better-limit-submission-per-time-period-by-user-or-ip/comment-page-10/#comment-309316
Is there a way to just buy this without some sort of subscription model? We just want a plugin, not a subscription. It depends on if this plugin works too, rather than needing an update.
Edit: We’ve purchased and installed the perk on both sites, it works as intended, thanks for the tip. Just a shame it’s a subscription model.
Hi Joe, glad the plugin works for you. We’re happy to have you as a Gravity Perks customer! Subscription models make sense for software that is intended to be updated indefinitely over time. Check out our weekly updates. You’ll see that we’re constantly making fixes and improvements to our perks every week! ?
Another heads up to say this doesn’t work with Gravity Forms 2.3.2
Any ETA on a revised version, this is a pretty mission critical snippet and we love it! Many thanks.
Thanks for the heads up. This snippet is in the queue to be updated. Given that this is mission critical to you, I would highly recommend the plugin-version:
https://gravitywiz.com/documentation/gravity-forms-limit-submissions/
Hi,
Does this code only work if you have the GravityWiz/GravityPerks plugin on your site?
Hi Sannah, no this snippet works directly with Gravity Forms. The perk-version of this snippet which provides an easy-to-use UI and enhanced functionality does required Gravity Perks.
It looks like this plugin is not compatible with the latest release of gravity forms?
PHP Notice: An outdated add-on or custom code is attempting to access the ocp_rg_lead table which is not valid in this version of Gravity Forms. Update your add-ons and custom code to prevent loss of form data. Further details: https://docs.gravityforms.com/database-storage-structure-reference/#changes-from-gravity-forms-2-2 in /nas/content/live/asolutions/wp-content/plugins/gravityforms/gravityforms.php on line 5094
I’m getting duplicate lead submissions after today’s update, so I am only assuming this plugin is no longer functioning (and therefore the culprit.) Thanks!
Hi John, yes, this snippet will require an update to work with GF 2.3. We have started a queue for getting these snippets updated. We’ve added your request to this queue. If you’re a Gravity Perks user, send us a support request and we’ll move your request to the top of the queue. Though in this case if you are a Gravity Perks user you would probably want to use GP Limit Submissions instead of this snippet anyways. :)
Hi there,
Great snippet! I am using it, although I have some questions.
1. I would like people to fill out the form just once, but… If they made a mistake or would like to add something more, they should get the opportunity to modify the form.
2. I have implanted this search option for user to search other user that also have filled out the form. When a person is searched and found the page kinda loads again and then I am seeing the form again, that should not be seen.
Is there a way to solve this? Could you please help me out?
Thanks,
Olivier
Hi Oliver, we don’t have a solution for either of these. Sorry. :/
Hi
Thank you for this snippet.
I want to have a gravity form that only can be submitted once a month (or preferably every 14 days) by every user and I have copied the below code into the bottom of the functions.php file but I get an error message for the “limit message” line and the “limit by” line. Can you see what is wrong?
Thank you.
Best Regards
Hi Kenneth, looks like you’re missing a comma at the end of line 5.
Hi,
<
p>I’m trying to restrict a form to 1 entry per calendar year, for users of certain roles. It should roll back to allowing 1 entry after December 31st. However when I set up the feed and test the form, it keeps accepting multiple submissions from me even though I added the Administrator role to the limited group. I don’t see the message on the front end stating that I have reached my limit of submissions. See screenshot for my feed setup: [removed]
Also: is it possible to hide the form entirely from the user if their user account has already submitted an entry for the calendar year?
Hi David,
Thank you for this handy snippet!
I am running into problems getting my form to limit by IP. After some troubleshooting I have found that the
GFFormsModel::get_ip()
method is returning 127.0.01 on my local site and also on staging.It appears to be related to a recent Gravity Forms update: https://docs.gravityforms.com/changes-entry-ip-detection/
I went ahead and added the filter. This fixed my staging site, but unfortunately broke my local development site.
Have you seen this issue before? Any insight?
Thanks again! Chris
Hi Chris, when you say it broke your local dev site, do you mean that the functionality just didn’t work as expected or that there was some sort of actual error? If the latter, what error are you seeing?
Hi, When limiting by role, is it limited to each user? so If I limit it to two submissions by role “friend” does that mean everyone with the “friend” role can submit two each? Thanks
It limits per user by role. Each “friend” can submit two times.
Hi David,
Thanks for the great work!
Question, How would you limit by the combination of 2 fields? Situation: the same form is served on all single pages for camp fairs, and the form has a hidden field that also captures the id of the post, so I would like to block submissions if it finds a repeated combination of email + post_ID
Thanks in advance for the help!
Sorry for the multiple messages, but I would like to clarify what if the limit is based on the email and a custom field, i.e. email + event_date. Thanks
Hi Santiago, to limit by a group of field values, you can structure the initialization arguments like so: http://snippi.com/s/ool5gpt
That was perfect thanks!
Hi, is it possible to mix parameters liks this : only one time for form 26 and 27 and Limit 19 times for role administrator et 4 for subscriber
Thank you
Hi Alain, you can create as many instances of this snippet with unique configurations as you’d like. More info here: https://gravitywiz.com/documentation/apply-class-based-snippet-different-forms/
Hello
I would like to say that the perks bundle has helped greatly, however I’m stuck at this point.
I’ve configured a series of forms that enable us to sell gift vouchers for our restaurant. When a customer purchases a voucher, A query string link in a notification is sent to our office which contains all the information captured from the customer.
Our staff then input the details into our till system which then generates a unique code. When they click that link it takes them to a form where they need to input the unique code, the form is prepopulated with customer data from the query string.
Upon submission the voucher is sent as an attachment to the customer.
What I want to do is limit the submission to 1 per transaction. Can this code help me with that?
This snippet will allow you to limit a form to one submission you just need to identify what data you will use to uniquely limit the submissions.
It works! Thank you!
Glad to help, Matthew. :)
Hello! I work for a University that needs to use the form often. If there a way I can limit ALL IPS save for the School’s? Thank you!
You could limit by IP and set the limit to whatever you want for all non-University-IPs and then wrap the configuration in a check for the current IP. Here’s the rough idea:
if( not university IP ) { new GW_Submission_Limit( ... ) }
Just found this old example: https://gist.github.com/spivurno/4024503
Hey David. Thanks for Great Snippet! if i want user can do only one Paid Transaction and after show error for them that says “You can only buy one ticket” How can i configure? i use gravity view for show result and gravity form for submit. but also Cancelled Transaction Interference with my form and my limit not work good. Thanks
This snippet does not support only counting paid submissions; however, if you’d like to pick up a copy of Gravity Perks, we can send you the plugin version of this snippet and a little code snippet to limit by paid submissions with it. Drop us a line via support.
Hi, when is the plugin version of this going to be available?
Hi Mike, an early-access version is available to Gravity Perks users now. You can request it via the support form.
Hey David! thanks for Great Code but…One Thing if i want add 2 form and each form have different condition.. for example form 1: user can send 4 Entire form 2: user can send 1 Entire But Each form same fields. Now how can i add this snippet? Please Help me. :) Thank You.
Hi Smith, I think this will help: https://gravitywiz.com/documentation/apply-class-based-snippet-different-forms/
Hi – great snipped of code!
Is there a way to exclude a particular IP address or set of IP addresses, when using the limit by IP address option?
You would need to wrap the initialization in a check for the IP. Here’s an example: https://gist.github.com/spivurno/4024503
Hi thnaks for your code. is there any way to show Remaining times to fill out the form per user? thanks.
Not currently. The upcoming plugin version of this snippet will support this.
Hi David. which plugin can do this feature i want and when you update it? thanks
It’s called Gravity Forms Limit Submissions and an early-access version is available to Gravity Perks users now. You can request it via the support form.
Hey David. thank you for Code and Help but one Problem..!! if we want to take Quantity for Every User What should we do now? for Example i want each user just enter 4 entity on his profile and after 4th show error. User Registered is Leader and Want to enter 4 person on profile, each person have name and family and age and i want leader cannot register more than 4 user. Thank You.
Hi John, is the user intended to submit all four on the same submission? or are they submitting a form multiple times for each user?
How Redirect after Submission? i perform action and my page is refresh not redirect to Error Page for problem.
This should not interfere with a confirmation configured to redirect on submission.
Hi David, really grateful for this code, thank you so much for sharing it. One question (and maybe this isn’t the right place to ask, but): I’m limiting Gravity Form Poll users to 10 votes by IP, and a lot of users are finding that they are being blocked before they get a chance to vote.
Any ideas why this might be happening? I’m aware that users on the same network might all be accessing from the same IP, but it also seems that mobile users on cell networks are also getting blocked.
Hm, honestly not sure, Rae. The network issue is the only one I was aware of with IP limitations. You might consider having the user submit a valid email address and limiting by that instead?
Thanks very much David, I think we just had a lot of people on the same networks. Switched to limit by email and everything seems to be going much better. :)
That’s great, Rae! :)
Hi, David. I previously used version 2.8 of this snippet successfully. I updated the code to the current version, 2.14, but it crashed my site. I copied and pasted the text file straight from GitHub. Has anyone else reported this issue? Also, I am a Gravity Perks user and am looking forward to having this snippet available as a perk so I don’t crash my site. :)
Best, Rob
Hi Rob, I wouldn’t expect any fatal errors; however, if you’d like to contact us via the support form, I’ll be happy to send you the current beta for GP Limit Submission. :)
Thanks, I sent the email to support. By the way, the reason for the earlier error and crash was a rookie mistake on my part. I pasted the entire snippet into my theme’s functions.php file, including the leading <?php. Duh! If anyone else is reading this, don’t do what I did. Grab the rest of the snippet and ignore the leading line, <?php when copying and pasting.
Sorry, one more thing. Would you be able to tell me what’s wrong with the following configuration, please?
The resulting error message is:
Warning: in_array() expects parameter 2 to be array, boolean given in /home/theaacn9/public_html/wp-content/themes/theaacn/functions.php on line 412
In my theme’s functions.php file, line 412 is “$is_specific_form = ! $this->is_global( $form_id ) ? in_array( $form_id, $this->_args[‘form_ids’] ) : false;”
I am simply trying to prevent double clicks on the Submit button for all the forms on my site.
Best, Rob
Hi Rob, I would expect that configuration to work. This will be a non-issue once you’re running GP LImit Submissions.
Hey,
This seems like a great snippet, but I am having issues with it.
I am using a paged form (3 pages in total) – When I apply the restrictions of limit:1, per day and by ip, I get the limit message appear on the last page, instead of the forms last page?
I’m not sure I understand?
Gravity forms has a page option, so my form is spread over 3 pages, with the submit button on the 3rd page.
But with your code in place, instead of seeing the last page, I get the ‘limit_message’ text instead. I can take a screen recording if I am able to email you?
I have found the cause of the issue:
“Gravity Forms Partial Entries Plugin” – because this plugin is saving the data as you progress it’s somehow breaking your code snippet :(
Ah, interesting issue. We will look into addressing this in the upcoming plugin version of this snippet. If you’d like to take that for a test-drive, pick up a copy of Gravity Perks and drop us a line via the support form.
Hi David – Is it possible to use this snippet by limiting a user from submitting a form OR conditionally showing/hiding a field if a specific time has not elapsed.
For example, only allow this form to be submitted before 7PM local to the user’s GEO data or only display said field before said time.
Thanks!
GP Conditional Logic Dates would be a better fit for that. It allows you to prevent submission by hiding the submit button via conditional logic. You can show/hide the field via conditional logic as well.
Thanks for responding David.
GP Conditional Logic Dates with the timestamp is something that has to be set up manually.
In other words, I cannot have it to work in a way where each day at 7PM local time to the user hide the submit button?
Hi Zeyad,
GP Conditional Logic Dates now supports comparing by “Current Time” which is the user’s local time. Here’s what that would look like (screenshot).
Thanks so much for this snippet. I’d like to prevent duplicate submissions for 60 seconds. When hitting the back button back to my Gravity Form from my ecommerce site the form is adding a duplicate product to the cart because the Gravity Form is resubmitting again. Does this code look correct? Thank you!!!
Hi Kerry, that looks correct. Try testing via the GF form preview. If it works there, there is a likely a conflict with your ecommerce software.
Thank you, David! Unfortunately, when I add the functions.php file to my child theme, I’m getting error below and the site goes down. Any idea what might be the issue? Here’s the error log:
Hi Kerry, you need to include the full snippet. Your code only includes the bit that instantiates it right now. More details here: https://gravitywiz.com/documentation/snippet-troubleshooting/
Thank you so much for the snippet and for your help!!! I was able to get it working but am seeing some strange behavior. My form is here: http://elephant-books.com/join/
Using Chrome on MacOS: I make the selection from the Get Started Gravity Form, click continue, land on Checkout page showing selected item in the order. Click back button. Briefly see the Get Started form before page jumps back to Checkout, now with 2 items in the cart. Click the back button again and this time I don’t go to the Get Started page but instead leave the site altogether to whatever the previous site I was on was before clicking elephant-books.com.
Using Safari on MacOS: I make the selection on Get Started Gravity Form and click continue to Checkout page. Click back button and am shown previous Get Started page. The churning symbol is showing in the left corner of the form. Efforts to click on continue or make a different selection and click continue do not cause any reaction. Manually pushing the forward button returns me to the Checkout page with only one item in the cart.
Below is my config code.
Any thoughts?
Thanks again!!
Hi Kerry, it sounds like there might be some sort of conflict in the way your cart is interacting with Gravity Forms. Are you able to recreate this same behavior in GF preview?
Hi David,
Seems to work fine in Chrome when in Gravity Forms Preview. Does that tell you anything that could help solve the issue? Thanks for your support!
Hey Kerry, this tells us that the issue is with how your GF + eCommerce integration is processing the form submission. Unfortunately, this is beyond what we can troubleshoot pro bono.
How can I configure this plugin so it would limit the users AFTER they submit the form? This is like a sign-up form for trial usage. I have No Duplicates enabled for email field and it works perfect. Now I would like to also limit by IP address as some users will make new email accounts in order to use the trial period multiple times.
But I get limit message before the form even appears. Can I achieve to be shown after the form has been submitted?
This does limit after the user has submitted the form. You’re only seeing the limit message because you’ve already exceeded the limit.
Hi David,
I am trying to limit the use of our form to once per month per ip address.
Am I doing something wrong?
Kind regards,
Mark
No, that looks correct. I tried the same configuration on my end and it worked as expected. If you’re a Gravity Perks customer, we’ll be happy to provide additional support via the support form.
Great snippet works nicely, I also have Gravity View used to display my submissions and am using the plugin also to allow editing of submissions. I am currently limiting my form so a user can only sumbit 3 times and it works perfectly for the actual form the only problem is, when a user clicks the edit link the message is displayed instead of the filled out form for editing. I would like to still use this snippet is there a way I could use this snippet and have the edit form working? Thank you!
Try instantiated the snippet like this:
Thank you for your response, I tried instantiating the snipped like that and now it is not even limiting my form, I have my Gravity View Table above my form and they are both displayed on the same page.
ex: TABLE OF TEAMS //displays all teams
FORM TO REGISTER TEAMS //when reaches max teams display message
Updated version:
Thank you so much for your help David, but the snippet is limiting now but not allowing me to edit my entries using a Gravity View display, it is doing what it did before thinking that the edit entries form is an actual form. I tried using the “embed_url” limiter and it works perfectly except whenever I go to a single entry using Gravity View the form displays because it is a different url. This is what code I put in, I may be doing something wrong.
Hey Miles, it looks like we’ll need to dig deeper on this. This is outside of what we can offer pro bono; however, if you are a Gravity Perks user, we provide complimentary support for our snippets via the support form.
Okay, thank you David for your time and effort, I really appreciated the help!
I finally got it to work, for anyone who is wondering how here is the code:
WARNING, this snippet for some reason causes some issues in the WordPress back end. Using this plugin: https://wordpress.org/plugins/code-snippets/ instead of adding the snippets to your functions.php file and then using the plugin’s settings to make the snippet only run on the WordPress Front End will solve these issues.
Where do I paste this code snippet exactly? I put it before the regular theme’s <?php tag and it crashed my website. I also put it after all of the regular function.php code and it crashed my website also.
I am trying to paste the whole code provided for the snippet. the <?php tag and all.
Try this Miles: https://gravitywiz.com/documentation/snippet-troubleshooting/
Hi David, what I want to do is- login user can fill out info and submit the form the first time. Next time they click the same link, the form with the old entry data will show up on each field and they can only EDIT and save. Is there a snippet that can do this? If not, how can I achieve this? thanks.
This might be a good fit: https://wordpress.org/plugins/gravity-forms-sticky-list/
thanks David. I use the gravity-forms-sticky-list with this snippet, when I click EDIT, no form will show; when I disable the snippet, the form shows for update OK. What cause the problem, please help.
I try to limit the form 1 per user, and they can only edit after submission.
Hi Jack, the snippet does know the difference between the initial form submission and subsequent form submissions with the sticky list. You’ll probably need to hire a developer to make these play nice together.
Hi
Great (very useful) snippet thank you. I’m using the Multiple Limiters as shown above, but how do I apply the same rules to multiple form ids?
My code is for form ID 14 but I have another 4 forms I want to apply the same rule to.
Hi Ryan, this will help: https://gravitywiz.com/documentation/apply-class-based-snippet-different-forms/
Hi, is possible to limit more than one form by role with different limits for each form?
Hi Omar, yes, you can configure this for as many forms in as many ways as you need. https://gravitywiz.com/documentation/apply-class-based-snippet-different-forms/
I have added the code in below and it work fine for both form but for some reason it also limiting my form ID 2 even though i have not added any limits for that ID/
Hm, I’m not able to recreate locally. Only the specified form IDs are limited on my end. We provide complimentary support for our snippets to our Gravity Perks users. Feel free to pick up a copy and drop us a line via the support form.
Hi,
Thanks for the snippet. I’m hoping it will solve my issue, but I could use a pointer… My goal it to have the for so that user from one IP can submit the form once a week, but the ‘time_period’ only has day, month and year as parameters.
Would be great if you could help me out on this.
Thank you!
Hi Joni, “week” is also supported. :)
Thanks David. Question, is this function available through Gravity Perks or just a snippet?
Currently, just this snippet. We are getting very close to releasing the perk version. :)
This is so helpful – thanks so much for sharing it! I had a question… I only need to limit my form to one entry per user – ever. I have used the snippet setup as below… will this work? Or do I need the field value line as well?
That should do the trick. :)
Great. Thanks for checking it :)
Hey there – this code actually caused a new problem on my form. While I want to limit a users entries – I still want the user to be able to edit the form. This code turns editing off. Is there anyway I can just limit the initial entry – not edit?
Are you editing with Gravity View?
Yes – with GravityView
Hi Justine, I just shared this with another user doing the same thing but he said it isn’t working for him. Feel free to give it a try. If it doesn’t work for you and if you are a Gravity Perks user, we provide complimentary support for our snippets via the support form.
Hello Justine, I see you had the same problem as me I used this code here to solve it:
Thank so much – going to try it. Will let you know how I make out!
Welcome, let me know if it works out for you!
HI – I tried both of these and both cause issues on my site. The page won’t even load when they are activated. Not sure what’s going on but they don’t work for me.
Hi, yes soon after I posted this I realized that I couldn’t access some of the tabs in the WordPress back end. It seems to me that the snippet is running in the wordpress backend which is causing some problems I am using a Snippet importer plugin for my website so I do not have to go into the functions.php file everytime and all I have to do is put in the snippet code there. This plugin also has settings where you can select where you want this snippet to run: “admin panel or front end only”. I then selected front end panel only which fixed the problem. Sorry, I didn’t mean to mess anything up. The link to the plugin I am using is here: https://wordpress.org/plugins/code-snippets/ it runs snippets the exact same way as if you were to put it into your functions.php, try this out and let me know if it helps. Sorry.
Hi Miles – I was already using the code in snippets. I have tried front end only after your suggestion – but still causes the same problem. Guess I’m looking for another solution! Thanks for your help.
Hi, is there a way to display the limits and the remaining available entries somewhere in the form?
Hi Ste, you might find this answer helpful: https://gravitywiz.com/better-limit-submission-per-time-period-by-user-or-ip/comment-page-6/#comment-271245
(1) Any chance you’ll ever be turning this into a plugin, for ease of use by non-coders?
(2) Is there a way to shorten the amount of code if all we want is to limit all forms by IP address to one submission (per form) per day (no user/role, or field limiters)? I like to limit functions.php code whenever possible to prevent possible errors in the future. Maybe I’m weird.
Hi Rachel, the plugin version is about 85% done! There is no simple way to compress the code.
Hi David, I use the one “Multiple Limiters” above to limit each user can only submit one entry on my localhost running WAMP. every time I reboot my computer, the form reappear again and the user can re-enter a form. please help.
Hi Dan, I’m not able to recreate this on my own local server. It sounds like you’re having some sort of configuration issue; perhaps you database is being reset somehow? If the entries are still in the Gravity Forms Entries List view, I would expect this to work.
thanks David. another question is how to redirect a user to another page. I want to change the line ‘limit_message’ => ‘Aha! You have been limited.’, to something like “EDIT Page”, so the user can click and edit their entry, or directly go to that page. (2) what add-on or snippet can let a user to edit his/her own entry at the frontend?
Hi Dan, this snippet will not readily handle a redirect without customization. The matter of editing an entry can be accomplish with this snippet:
https://gist.github.com/spivurno/32e914d67723f89717be2904ce6234c4
Hi David, I copy the snippet you give https://gist.github.com/spivurno/32e914d67723f89717be2904ce6234c4 to the functions.php. then I input data as normal at the frontend and submit. the second time I click the form nothing populate, did I do anything wrong, please help.
Hi Dan, we’ll be happy to provide support for this snippet via the support form.
This is a great snippet! I installed it as a plugin and I was able to make it limit by email address, but is there a way to make it limit by credit card number? I’m not sure how to specify the subfield for the card number itself (eg. 15_1 or 15.1). using and underscore crashes the page. using a period doesn’t make any result.
Hi Michael, this worked for me (will need to be updated for your form).
Haha, yeah, naturally I tried that just AFTER posting. Thanks again for the great snippet and for your help!
Glad to hear it’s working, Michael. :)
Hi, thanks for the great article, Is there a way to make it work even if the admin on the Form Settings page enabled the entry limit in the Restrictions section?. I’m saying this because I’m trying to limit the submissions by email(1 per day) and it works great but only when “Limit number of entries” is not activated.
Thanks
The “Limit number of entires” setting limits by the total number of entries. If that is enabled, it will always override this snippet if the total entry limit is exceeded. Could you elaborate on your use-case for needing both?
I’m trying to use the form for giveaways, and users can submit multiple times (1 per day). When I use the Form settings to Limit the number of entries, the user is getting blocked by IP, but I would like them to be blocked by a field (email) so multiple users can vote from the same computer.
In other words, I would like to change the default blocking mechanism (by IP) to something a little more permissive (by email). The question would be if is there an easy way to do that?
Thanks for sharing your expertise!
Just to confirm, do you need to limit by total entry count?
I need the form to be blocked by email. (by default it blocks it by IP)
So multiple users can submit the form from the same computer as long as they use a different email BUT they should also have the restraint of once per day, so at the next day you can submit the form again using the same email.
Based on your first response I’m guessing the only way to achieve this is by not setting anything in the admin area, and adding the code snippet in functions.php
I was looking for a solution that didn’t need me to add stuff to functions.php for every form that needs this functionality, and at the same time hope that nobody sets anything in the backend because it will override the code snippet.
Hope that clarifies what I need, and sorry for any missunderstanding, English is not my first language. thanks
I understand. This snippet will not override the default Gravity Forms setting. Your understanding is correct. You would need to deactivate the form setting and only use the snippet. Here’s how you can limit by 1 email per day.
Thanks for this! This is just what we were looking for and seems to be working as expected!
Glad to hear it, James!
Sorry I have another question. For some reason this isn’t limiting a submission from posting when the user hits the back button in the browser after a submission. I would have thought it would do that, do you have any suggestions on how to go about this?
Hi Anthony, I’m not able to recreate this issue. Hitting the back button allows you to see the form again but the extra submission is blocked and returns validation error.
That’s so weird. Could it have anything to do with caching? My form page has Cache-Control:no-cache, must-revalidate, max-age=0
Unlikely. Each submission is a POST request which are almost always excluded from cache. It is on the POST request that the validation is triggered and what will catch erroneous submissions.
Hmm, okay I’ll dig deeper and will report back if I figure it out in case any else runs into the same thing. Thanks :)
Okay, so it does seem to be preventing the entry, but for some reason Chrome was still following the confirmation redirect. In Safari and I got the expected form validation error message.
Hey,
Great snippet. I’m including it in a file that I require from functions.php, however I want to use it in a plugin of mine, but then it does not recognize the GW_Submission_Limit class. Not sure if plugins are called before functions.php and that’s the issue? If not, how should I use this snippet if I want to have it in a seperate file required from functions, but use it somewhere else? It does work if I use require_once to load the snippet from the plugin, but preferably I wouldn’t have to do this since its already required from functions.php.
What am I doing wrong? :)
Hi Johan,
If you want to include this in a plugin, you just need to make sure you’re not initializing the snippet until after both the plugin and snippet are loaded. Try initializing the GW_Submission_Limit class inside an a function on the “init” hook.
What’s the purpose of this line? I don’t see any reference to GWSubmissionLimit
Which line?
Sorry I pasted it in the ‘code’ section, but it didn’t come through for some reason. It’s below:
class GWSubmissionLimit extends GW_Submission_Limit { }
The snippet class was previously GWSubmissionLimit. This line is for backwards compatibility with people who may still be initializing the snippet using the old class name.
This is awesome code, thanks so much for supplying it. One question though would it be possible to redirect a user to another page when they reach a limit?
Hi Ivan, this snippet does not currently support that. I’ve added it to the feature requests. :)
It looks great. The only issue I have with the code is when I am trying to limit by IP. It limit on Google Chrome and Firefox, but not on Internet Explorer.
Any suggestions?
Michael
Hi Michael, I’m not able to recreate this issue. We have a plugin version of this snippet that’ll be available soon(ish). It will include support so if you’re still having this issue we’ll be happy to dig in.
Hi,
This works well.
A bit out of topic, but how can I use the back button in browser to send the form again, now I have to reload the page…
Thanks a lot
I’d recommend GF Reload Form: https://gravitywiz.com/documentation/gravity-forms-reload-form/ for the optimal user experience. It will allow you to click a link to reset the form immediately – or – you can automatically reset the form after x seconds.
Hi there,
This is a great snippet! How ever, I get stuck when I try to use the limit by roles section. My code is attached, please could you tell me if there is any reason it should be crashing the website?
Also, I had to remove <?php from the top of the snippet to prevent the site crashing, I think that is normal?
As you can see I am a bit of a novice, but am a great fan of your site! I would love to work out how to use this roles part.
Thanks!
Hi Dan, it looks like you’ve specified the “limit” parameter twice. Try removing this line:
'limit' => 1,
Hi there
I tried that but it didn’t make a difference. Are you sure this should work:
thanks, see attached code:
Hi Dan, I confirmed your configuration is working on my end. If you need additional support, we do offer complimentary support for our snippets to our Gravity Perks customers. Alternately, if you’d prefer to have us install the snippet for you, we provide that service as well.
Hi, I’m also having problems with roles – I’d like to limit to specific roles but not ‘administrator’, I’m guessing I can just leave out ‘administrator’, or do you need to put ‘administrator’ => false, ?
Cheers, David
Hey David, if you don’t want a role limited, excluding it from the list or role limits all-together should do the trick.
Is it possible to limit a form field_value to a specific user? I have a form that logged in users fill out multiple times. If a person enters in a specific value into one field, can I make it such that nobody else can use that value? However, the original user can then come back and use that value themselves.
This is a cool use case but it is not currently supported. If you’d like to hire me to add this feature, get in touch.
Hi. This snippet is really perfet for me. Unfortunately i’m not a developer. In which part of function.php dp I have to put the script? I’ve tryied but it crashed the site.
Thanks a lot! :-) Luca
Hi Luca, this will help: https://gravitywiz.com/documentation/snippet-troubleshooting/
Is it possible to limit by total field value over a time period? For instance, a form field has the option of 1-5 that they can select. Can you set the limiter so that once they reach 5 for the month, they can’t submit any more. So if they submit the form and select 3, they could either submit it two more times if they select 1 or one more time if they select 2?
Hey Ruben, we do not currently have a solution for this one. the Better Inventory snippet would do this sans the time period.
Hi, kind of a newbie question: I have several custom functions in my functions.php file, but those are all defined with the “function” keyword. What’s this “new” syntax? What are we creating a new instance of?
Sorry I didn’t see that block of code with the class definition. Thanks!
Hi AG, the snippet contains two parts. The definition and the initialization. You define the “class” once and then you use the new keyword to create as many instances of the class as you needed. Here is a doc with more details: https://gravitywiz.com/documentation/apply-class-based-snippet-different-forms/
Hi,
I installed the snippet, but it doesn’t limit my submissions
Here’s the code I’m using.
I want to limit by day. I don’t mind if it’ll be 24 hours or calendar day.
I tried using “per_day”. Got form error message “there’s something wrong with your form marked in red” (nothing was actually marked)
I tried using 60 * 60 * 24. No limitation. Also when using 86400 value.
Needless to say all form setting in code are correct.
Thanks
Hi Asaf, drop us support request. There are some issues with your configuration.
https://gravitywiz.com/support/
Hi,
Can I use several LIMIT BY and LIMIT to be able to limit, for example, per role and field type at the same time? or perhaps I must use several new GW_Submission_Limit instances?
Thanks a lot
You can limit by several things by passing an array to the “limit_by” field; however, you cannot pass separate limits for each limit_by parameter. If you need to do that, you would want to create a new instance for each type of limit.
https://gravitywiz.com/documentation/apply-class-based-snippet-different-forms/
Hi David!
Is there possible to add shortcode into to the “limit_message” so when user reach the limit, it can show content of shortcode instead of text?
Thank you for any help!
Hi Reinald, you would need to update the snippet to call do_shortcodes() anywhere the limit_message parameter is referenced. :)
David,
Thank you for replying. I know that I should call do_shortcodes() in my functions.php file but I’m not exactly sure if it works, because I added and tried this but it didn’t work:
Hi Reinald,
You’ll need to do it when the message is being output to the screen (not in the configuration). If you search the snippet, you’ll see where the “limit_message” parameter is echoed out. Just wrap that in a do_shortcodes() call and you should be golden.
Hi David,
Thanks for this. I’ve been using this on a site for a while and I may have run into an issue.
I realized that there are users who are blocked from seeing a form (which is limited to one submission per user, per month), although their last entry was a year ago.
I looked a bit through the code logic and I think that for the per_month option, the code compares the month of the entry to the current month (maybe without taking the year in consideration).
So if we use March for example, it compares March to March instead of March 2016 to March 2017.
The other thing is that I thought that the per_month option is more based on period than on calendar month – so I thought it would calculate number of days since the last entry, which to me, would make more sense.
The reason is you can fill a form on say March 30 and then another on April 2 and you’d get basically two consecutive entries. For my purpose, the goal of limiting per period (per month) is to trying to prevent users from ordering too many things in a too small timeframe.
Just wanted to bring this up see if you have any ideas? I wasn’t able to run too many tests on this topic, so maybe you could clarify these points.
Thanks.
Hi Andrei,
You were correct about the month and week time periods limiting across all years. This has been fixed and updated above. Thank you!
As far as limiting by non-calendar-months, the “time_period” parameter supports a time period defined in seconds. For example, here is how you could specify a month in seconds:
'time_period' => 60 * 60 * 24 * 30,
David,
Great, thanks, will do!
David,
I updated the script to 2.12 and the problem seems to still exist. If a user has an entry in March 2016, the form is limited, even though I changed time_period to be in seconds instead.
I also tried with ‘per_month’ as before with 2.12, without success.
Are you able to run some tests on your end to verify?
Thanks.
Hi Andrei,
I’ve confirmed that 2.12 is working for me locally. I tested both the “per_month” and the time period in seconds. If you’d like us to dig deeper, we provide an additional level of support for our Gravity Perks license holders.
https://gravitywiz.com/support/
Hi, one more issue…
I´m using Stickylist to update forms but if limit is reached I can´t edit.
Any ideas?
Thanks again
This snippet only counts submissions, it doesn’t check if it’s a Sticky List submission or not. If you work with the Sticky List plugin developer, he would probably provide some advice on how to determine if the submission is a sticky list submission.
Hi, great snippet!!
Can I limit for userid and role at the same time?
I need authors to be able to send 1 form, but administrators and editors shouldn´t be able to send any.
Thanks
You can provide an array of roles to limit by:
‘limit’ => array( ‘administrator’ => 0, ‘editor’ => 0, ‘author’ => 1 )
Hi again,
Thanks a lot for your answer.
Perhaps I’m missing something…
I need only authors can send one form but every author must be able to send one.
How can I achueve that.
Thanks a lot
I’m not sure I understand?
Hi David! thanks a lot for the code! Im trying to create a cancel rule to limit its functionality when used with gravityview so that new submissions work with the limits but updates remain fully open and accessible. I’ve had some help from help from the gravityview team but its still missing something as im still getting a limit on the edit pages. Im sure this would be extremely useful for many other people. Can you please help? This is the code by Zack: https://gist.github.com/zackkatz/d361149f4961c7d0c67a50d6e959357d
Thanks a lot!
Hi Tal, I think this might work better for you: http://snippi.com/s/ixxlshv
Hi David,
Thank you! I’ve actually tried the code but it didnt work for me. Can you please explain how to modify it to work? Im still getting restrictions on the gravityview edit form page.
Hi Tal, unfortunately, we’re not able to provide the level of support required pro bono. If you’re a Gravity Perks customer, we provide complimentary support for our snippets via the support form.
Hi David,
Going to register as a customer. Thanks.
Hi there! This is working great for what it says it does and I’m super grateful to you for putting the code out there for all of us to use!
I want to take it a step further and not quite sure how to do that. After limiting the user by their role, I want to show them the number of submissions they have left in that time period (I’m using month, defined by seconds). So, if a specific role has 12 per month and they’ve used 5, they should see that they have seven left.
I tried using the shortcode fix, but that apparently pulls on the overall form and I don’t have a submission limit on the whole form.
Any ideas?
Hi John, possible solution for you: https://gravitywiz.com/better-limit-submission-per-time-period-by-user-or-ip/comment-page-6/#comment-267622
Thanks David. I’m getting a “Call to undefined method GW_Submission_Limit” error. I pasted my code.
Are you including the full snippet?
I have a bunch of other custom code in there to suit my needs, but this is the full file.
Hm, not sure, John. If that is the full file, I can’t see any reason why that error would be generated.
It’s something to do with the code here snippet you linked to. I tried to just implement that and it threw the same error.
Is it possible that get_entry_count isn’t defined with my functions.php?
Ah, yup. You’re using an old version of the snippet. It’s up to 2.11 now.
Alright, we’re making progress and getting new errors! Now I’m getting a “Call to undefined function wp_get_current_user()” error, which is really weird. Going to make sure GF is all updated.
I’m still getting “Fatal error: Call to undefined function wp_get_current_user() in /nas/content/staging/upcraft/wp-content/plugins/credo-plugin/vendor/class-gw-submission-limit.php on line 276” when I try to implement the echo’s at the bottom. Any ideas?
Hi John, I’d recommend taking advantage of our installation service: https://gravitywiz.com/services/
Hi David, I’d do that if I knew what access you’d need to my site etc before I check out and pay.
WP and FTP.
Hi David – this is a really useful snippet, thank you
Is it possible to exclude a specific form? I see that we can use an array to include a range of form IDs, but I’d really like it to apply to all forms, except a specific one – so that you don’t have to update that array every time a new form is created.
Basically, it’s working nicely to limit the forms that I want to limit, but I just realised that it will be limiting my ‘contact us’ form too :-/
Hi Paul, if you don’t have hundreds of forms, here’s an approach you can use to do this.
Thanks so much for taking the time to help, much appreciated
Unfortunately, that approach didn’t work for me though – I think I understand the approach (i.e. create an array of excluded form IDs, and make the limit conditional on the form ID not matching an ID in the array) – but with that extra condition, it does not appear to apply the limit to any forms.
On debug, I get the following notice: Object of class stdClass could not be converted to int in [filepath-to-my-plugin-containing-the-full-snippet] at line 305 – that line is reproduced below.
Any further advice you can give would be much appreciated. thanks, Paul
An error with my original code, try this:
https://gist.github.com/spivurno/95ab9158843927face2e0c2831ab9774
Works perfectly – thanks so much for your help!
Hi David,
I am using this, and it works great, but while I edit my entry using gravity view, I am getting an error that there was a duplicate. How can I make this check only for the new submission instead of updates as well?
Thanks
Hi KA, this isn’t tested but I think you could probably get away with checking if you’re in a Gravity View before initializing the plugin. Something like this:
http://snippi.com/s/ixxlshv
Buenos días, Tengo un problema con los formularios de Gravity form y no sé cómo solucionarlo. Tengo una página en construcción y uso estos formularios +stripe para comercializar 4 productos/servicios. Cuando le doy a tramitar el pedido aparece el mensaje de confirmación, he elegido la opción de realizarlo en una página, y hasta ahí todo bien. El problema está cuando le a la flecha de ir hacia atrás en el navegador, me vuelve a aparecer el formulario y el solo vuelve a tramitar el pedido. Desde el soporte técnico del plugin me dicen que es un problema de los navegadores, ajeno a ellos y que una opción sería marcar en algún campo la casilla “sin duplicar”, pero veo que esta solución traerá más confusión al usuario. Sabéis si esto se puede arreglar?, o la solución más sencilla seria realizar esa confirmación con la confirmación por defecto de texto? Muchas gracias por vuestra atención. Saludos, Javier
Here’s how I would approach this.
So, this will populate a Single Line Text field on your form with a Unique ID. The No Duplicates feature will prevent the same unique id from being submitted twice.
Hola de nuevo, Voy a realizar los pasos que me has especificado, pero soy algo novato en esto y temo equivocarme.
Ya tengo instalado Gp unique id.
Esto debo pegarlo en functions.php del tema que utilizo o en el plugin Gravity form?. Yo utilizo un tema hijo, en el caso de tener que pegarlo en el tema, estas ordenes no se borraran con las actualizaciones del tema?
El texto que debo poner en Dynamic Population parameter on the Advanced tab, es simplemente “uid” sin las comillas.
Gracias por tu tiempo y atencion,
Un saludo, Javier
I’m hoping you can provide the exact configuration I need if I want to block certain users by their first and last name. It’s a long story why the client needs this. We need a way to block the form submission from approx 10 different people, by using their First and Last name. In our form, these are two different fields. I was messing around with the below configuration, but how do I account for the two field set, AND include multiple names?
Hi Natalie, here is how you limit by a group of inputs: http://snippi.com/s/kwa8yt3
Can you clarify how the time comparisons such as ‘per_day’ are done? Are WP timezone settings used?
If I recall correctly, GF stores date_created as UTC time but adjusts it for the WP timezone for display, export, etc. If you use UTC time for a comparison and a visitor is in the ET time zone, the date change will occur at 7 pm instead of the expected midnight.
Am I correct? If so, is there a simple fix, even just to use a set timezone such as ET by subtracting 5 hours from the UTC time?
Hey John,
I did a test to confirm and it looks like the date_created is the raw UTC timestamp. You are correct in that what constitutes a day will not align perfectly with every user’s midnight.
This is something we’ll dig into with the plugin-version. For the snippet, you can probably alter the SQL to handle this logic. See line 162.
Thanks for confirming.
To clarify, no matter what you do, you can’t align with every user’s midnight. I think for the plugin version, you should aim to align with the WP timezone setting for the site, whatever that might be.
That way, at least the site owner gets to say that things align with the site owner’s midnight.
Thanks for the input, John. My thought was to save the user’s local time via a cookie (so it is accessible server side) and then you can offset the search range for the day based on their specific timezone. Thoughts?
For my current use case, having the day defined per user wouldn’t work.
It’s a contest where the form is used to collect entries limited per day based on the rules of the contest. In this situation, it’s common for the rules to be written by the site owner and to specify a uniform time zone, such as the time zone of the site. Having a uniform day is important because it allows setting entry deadlines, picking a winner from among entries on a set day, etc.
You already allow a timing model that is relative to the user/entry (ie, a floating 24 hour period). I view the calendar timing as more fixed, and the control for fixing them should be in the hands of the site owner.
Maybe there’s a good use case for your description, but I haven’t come across it.
Thanks again for your input, John.
No, thank you. I tried modifying the SQL like this:
$time_period_sql = ‘DATE( strtotime(date_created, “-5 hours”) ) = DATE( strtotime(utc_timestamp(), “-5 hours”) )’;
That doesn’t throw any errors, but it doesn’t work.
Do I misunderstand what you’re doing with $time_period_sql or do I have an error in trying to subtract 5 hours?
Any help is appreciated.
That’s all MySQL so PHP functions won’t work there. I think something like this might work:
$time_period_sql = ‘DATE_SUB( date_created, INTERVAL 5 HOUR) = DATE_SUB( utc_timestamp(), INTERVAL 5 HOUR )’;
Thanks David. Unfortunately, that didn’t work.
This works (your original code):
$time_period_sql = ‘DATE( date_created ) = DATE( utc_timestamp() )’;
This does not work:
$time_period_sql = ‘DATE_SUB( date_created, INTERVAL 5 HOUR) = DATE_SUB( utc_timestamp(), INTERVAL 5 HOUR )’;
Maybe doing math in the SQL statement just won’t work (:
Any ETA on a version that might fix this? Fixable for a price?
Hello, thanks for the great snippet here!
I was wondering if there is a way to show the remaining amount of submission left for a logged in user if this is set by user role, per month. Ideally, this would show in the header.
I sell monthly subscriptions where people can submit documents for review.
Thanks!
We don’t have a shortcode (it will be available when the plugin-version of this snippet is ready); however, here are instructions for retrieving the desired information. You could wrap this in your own shortcode.
https://gravitywiz.com/better-limit-submission-per-time-period-by-user-or-ip/comment-page-6/#comment-267622
Thanks for the reply David, really appreciated!
I would have 2 other questions: – Let’s say a user switch plans and has now a new user role (one user role per plan), will the counter “follow” what has been already submitted during the period? – I’m not sure if this is native to Gravity Forms, but if so, let’s say I use an approval scheme were I only want “Approved” submissions to really count, would this be possible?
Thanks, and sorry if I go too far, I’m new to this!
If you’re basing it on the User ID, changing the role will not impact this. If you’re doing it by role, then the counter would reset.
Worked great to limit by IP. Thanks for the awesome code!
Glad to help, Dan. :)
Should the snippet work on complex fields, such as name or address? In a few quick tests, it doesn’t appear that it does.
Hi John, I assume you’re using the “field_values” parameter? If so, you’ll need to specify the specified inputs of the complex fields (i.e. 1.3, 1.6) and not the top level field ID (i.e. 1).
Yes, but to clarify I think it’s “field_value”, not “field_values”.
I specified the first and last name fields for a name field, along with the unmodified snippet, and it didn’t trigger an error for a name that had been been submitted in the same calendar day.
I also tried just applying a limit to one component of a complex field, such as 7.3, but that didn’t work.
On non-complex fields, the snippet works fine.
I would expect you configuration to work… but give this alternate configuration a try anyways (see related code).
Thanks. In a quick test on a name field, the alternate configuration worked. I’ll test address and dropdown when I have more time.
Merry Christmas!
Awesome! Glad to hear it. Merry Christmas. :)
Hi and thanks for this awesome snippet!
I hope you can help me solve an issue I can’t get the hang of: I’m managing a site with several forms and I need to have the same limit (in terms of field value) for some of them, but not all. By “same limit” I mean that if a user submits one of these forms, the limit should come into effect for all of the other forms in this group.
The code I used almost works, but it puts a limit for each specific form, and the users can submit any of the others, which is not what I am looking for.
I cannot set a global limit for all of forms in the site because the others don’t include the field whose value I am using to place the limit.
Thank you in advance for any help you can provide, Razvan
I believe you should be able to extend this base class and overwrite the is_applicable_form() method to support a group of forms. Here’s a rough example. Note the array( 1, 2, 3 ). This is where you would put your form IDs that should share the limit.
http://snippi.com/s/l2w8dd3
Hi David,
Thanks for the reply!
I tried replacing my code but got the same result. The limit is still not shared, but placed for each individual form. Is there something I’ve done wrong?
Regards, Razvan
UPDATE: I think I’ve solved it by changing apply_limit_per_form to false in the code attached. Thanks again for the help!
Regards, Razvan
Awesome! Glad you were able to get this working. :)
I have a form with a drop down list containing 4 items, each of the items is available 10 times, so when a user submitted a form with a given item, I like the next time to show the remaining items but also once it reaches 0 tell the user he gets on a waiting list. Any suggestions how to achieve that ? Is there a way to extend the drop down field with these options ?
Hi Thorsten, this sounds like a good fit for GP Limit Choices and this snippet.
Hi David,
yes looks like it, I just got the license, hope it does what it offers :-)
I’m confident it will. :)
Kudos. Using this to solve a recurring issue with duplicate orders. Thank you very much!!
Glad it help you, Steve. :)
Great article
Glad you think so, Yoshie. :)
Hi David,
Thanks so much for this code! It works beautifully! I was also wondering, like Roberto (https://gravitywiz.com/better-limit-submission-per-time-period-by-user-or-ip/comment-page-5/#comment-265691) if there was a way to show the user how many submissions they have remaining.
I have a user account page, and based on a user’s role, they are allowed a certain number of submissions per month. I’d like to output a message like “2 submissions remaining this cycle”.
Hi Doug, I don’t have a shortcode for this; however, I’m happy to share the basic code you’ll need to retrieve this information. Here’s an example with comments on the right hand side of the page.
http://snippi.com/s/hwhotvw
You’ll want to be running version 2.8 of the snippet.
https://gist.github.com/spivurno/4024361
Perfect, thank you! The subtraction calculation wasn’t working correctly for me, then I realized that
get_entry_count()
was returning a string rather than an integer.Works beautifully!
Awesome! Glad you were able to get this sorted!
Thanks for this code!
I got this installed, and I can get it to work for one form. But haven’t been able to add additional forms.
When I use: new GW_Submission_Limit( array( ‘form_id’ => array(6,7), ‘limit_by’ => ‘user_id’, ‘limit_message’ => ‘You have already voted.’, ‘time_period’ => false ) );
It doesn’t work. But when I just list one form_id. It does.
new GW_Submission_Limit( array( ‘form_id’ => 6, ‘limit_by’ => ‘user_id’, ‘limit_message’ => ‘You have already voted.’, ‘time_period’ => false ) );
Can anyone see my flaw?
Thanks!
Forgot to check the followup box
Hi Bradley, I think this will help.
Thanks David. That is what I ended up doing and it works just fine.
Hi David.
I have a voting type form which shows up on a post-type archive page (in each post output). So all posts are displayed and a user with the specific admin role of “Voter” can vote on each post. Also, the form will currently only show up if the user is logged in with that specific “Voter” role.
I have this in place where the voter is restricted to one vote per entry, but can I also hide the form or show my ‘limit_message’ on the front-end if a vote has already been logged for that particular user?
Thank you, appreciate any help.
Hi Jason, I’m not sure I understand. Could you elaborate?
Hello i am trying to use your submission limits snippet. I am trying to limit my form to one entry per user(subscriber) as its a competition. I tried to insert the following into my functions.php but when i tried to refresh my site i was getting a blank white page, remove the code from functions and it appears again.
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘role’, // when “limit_by” is set to “role”, “limit” must be provided as array with roles and their corresponding limits ‘limit’ => array( ‘subscriber’ => 1 ) ) );
Appreciated if can point me in right direction.
Hi Chris, this will help.
Hello! Thank you very much for this very useful snippet. I used it successfully to limit votes in an online election to one vote per user with the following:
new GW_Submission_Limit( array( ‘form_id’ => 29, ‘limit_by’ => ‘user_id’, ‘limit_message’ => ‘You have already voted.’, ‘time_period’ => false // forever! ) );
I then tried to use a second instance to prevent people from clicking the Submit button twice within 30 seconds on some of my other forms with the following addition:
new GW_Submission_Limit( array( ‘form_id’ => array(1,18,19,20,21) ‘limit_by’ => ‘user_id’, ‘time_period’ => 30 ) );
The above crashed my site. Clearly I did something wrong! A help desk agent gave me the following debugging information:
Parse error: syntax error, unexpected ”limit_by” (T_CONSTANT_ENCAPSED_STRING), expecting ‘)’ in /home/theaacn9/public_html/wp-content/themes/theaacn/functions.php on line 574
Please let me know if you have any suggestion on what I did wrong. Thank you very much!
Hi Rob, looks like you’re missing a comma before the ‘limit_by’ parameter:
‘form_id’ => array(1,18,19,20,21), ‘limit_by’
Thank you very much, David!
Hello, this is a great solution, I am setting up a competition that requires a weekly keyword to enter over 10 weeks.
Is it possible to restrict it to 1 entry per keyword and match it against their email? So that would basically mean limiting each email to 10 submissions in total. This is for logged out users only.
is this possible?
So does the keyword actually matter or just limiting it to 10 submissions per email?
Hey David, thanks for the reply. They have to have the correct keyword to win the prize and we also want to limit people from submitting mulitple times.
This snippet does not validate that the keyword is correct. If the keyword is static, you could simply hide the submit button unless the keyword is entered. This snippet will let you limit how many times a user can submit the form.
Hey, Awesome snippet, I’ve been looking for this for too long, and finally found it and worked great!
I Have a couple of questions though: 1. Is it somehow possible to show the entries left per user id? 2. How can I reset the limit for a specific user?
If I use per_day as a time period, is it really a calendar day? or just a 24 hour period?
Hi Brad, this is an actual calendar day. To limit by a 24 hour period, you can set the “time_period” to 60 * 60 * 24.
Hi David,
First up, this is amazing and thank you.
I’m having an issue getting this to work. I would like to have a field that a code can be entered into twice a day. Here is my code..
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘field_value’, ‘limit’ => array( // “2” is your field ID, “6” is your limit for this field ID 9 => 2 ), ‘time_period’ => ‘per_day’, ‘limit_message’ => ‘
YOU'VE REACHED THE MAXIMUM ENTRIES FOR TODAY
A MAXIMUM OF TWO (2) ENTRIES ARE PERMITTED PER PERSON PER DAY. YOU'VE REACHED THE MAXIMUM ENTRIES FOR TODAY, PLEASE COME BACK TOMORROW.
‘ ) );
I get an error as follows:
Warning: Parameter 1 to array_shift() expected to be a reference, value given in /home/ene3009/wp-content/themes/divichild/functions.php on line 226
Any ideas? That should work right?
Cheers, Wes
Hi Wes, just to make sure we’re not losing anything in translation, could you share your config code via a snippi?
HI David,
Bit of a delay on my end there, but really appreciate your coming back to me.
http://snippi.com/s/au7ou7x
Many thanks :)
Cheers > Wes
Hm, that looks ok… could you send me an export of your form as well? You should be able to reply to the notification you’ll receive for this comment.
Hey David, thank you for your work on this. Unfortunately I can’t make it work for now… I need to limit 4 forms, by roles and different time periods. So I just pasted your code and adapted the “basic usage” part. Here is the code I get for a single form. The problem is I always get the limit message (in the right language thanks to qtranslate-x, which explains the [:fr][:it][:en][:] tags).
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘time_period’ => 606024*365, ‘limit_by’ => ‘role’, ‘limit’ => array( ‘administrator’ => 10000, ‘superstar_editor’ => 10000, ‘hero_editor’ => 12, ‘master_editor’ => 7, ‘explorer_editor’ => 3, ‘first_editor’ => 2, ‘free_editor’ => 0, ‘premium_for_life’ => 0, ‘premium_user’ => 0, ‘subscriber’ => 0 ), ‘limit_message’ => ‘[:fr]Vous avez atteint le maximum de créations de pages permis par votre compte en un an.[:it]Hai raggiunto il massimo degli creazioni di pagine consentitti per il tuo conto nello stesso anno.[:en]You have reached the maximum number of pages you can create with your account within a year.[:]’ ) );
What am I doing wrong? Thank you in advance for your help, have a great day,
Emilien
I found where it came from: it was a specific function into my child-theme, which was calling global $current_user. I just had to change the way the user data is called. I didn’t suspect it at first because I placed your snippet in a custom plugin…
Seems to work perfectly now. Thank you!
Awesome! Glad you got this working. :)
Hello David! This looks very promising for my need:
We have developed http://jerseys.innovasport.com/ site, where a user asks to be notified on the launching of a product. We created a form (a custom post embedded in a modal window) where the user types his/her email, and a hidden field that saves the {embed_post:post_title} value. The problem is that I have many duplicated entries. I can’t restrict the mail field because one user could want information on more than one product, but I need to restrict to one email by product. User A email, Product A User A email, Product B is valid, but not twice or more of User A email, Product A. I hope I’m being clear. Basically, is there a way to prevent duplicated entries on multiple fields? Thx in advance!
It worked!!!!! Thank you so much! I just used new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_message’ => ‘Aha! You have been limited dude.’, ‘limit_by’ => array( ‘field_value’ ), ‘fields’ => array( 3, 4 ), ‘limit’ => 1, ) );
And then I saw that you figured this out. Glad you found a solution! :)
Yes, this is possible by limiting the “field_value” and then specifying an array of fields that should act as a “group”. Here’s an example: http://pastie.org/private/ezv84f6crzan12ynbqwlqa
In your case, you would want to include the email field and the product name field. This way, the limit of “1” means that the combination of a specific email and product can only be submitted once.
David, I just want to thank you again, this function should be a “native” version or an official addon (I even suggested it to support staf)f, it is so useful!!! You are saving us lots of headaches and problems. We appreaciate it!
We’ll be adding this as an official perk for Gravity Perks soon! Glad you like it. :)
Hi David,
I am wondering if this snippet might be massaged to help with what I’m trying to do: We get duplicate form submissions on a couple of our forms – One of which is a job submission form with a front-end file uploader. We receive the first submission, and then a day, two days, three days, four days later, we receive another one, this time without the attached uploaded file. Sometimes this happens many times for the same submission. The friendly folks at GF said to use a no duplicates within the form. The issue is that some of our customers use the form to upload several jobs in a row, and I am worried that if I turn on no duplicates on one of the fields, any subsequent submissions may be flagged and missed.. Can you think of a way to curb the duplicates, but still allow the user to use the form several individual times in the same session? Sorry if this seems complicated or off-piste from what this snippet is for.. Just trying to find a solution. Thanks for any insight in advance!
-Matt
Hi Matt, are the duplicates caused by the user deliberately submitting the same information twice?
Hi David,
I am not totally sure what is causing the dupes. The form is primarily a front-end uploader, and the ‘attach a file’ field is required. The dupes that come back are the filled out form, but without any file attachments. This is odd to me because I assumed that the form wouldn’t submit unless the required fields were satiated. The folks at Gravity Forms said that it may be that the page is getting refreshed after a submission, but I tested that and couldn’t recreate the issue. It’s all a bit of a mystery.. Any light you might be able to help shine would be awesome.
Thanks David,
-Matt
Hi, I’ve done paste (installing) this snippet and want to limit submit by ip address. I’ve embed my form to my WordPress site. But, I can still submit to the form twice.
$this->_args = wp_parse_args( $args, array( ‘form_id’ => 5, ‘limit’ => 1, ‘limit_by’ => ‘ip’, // ‘ip’, ‘user_id’, ‘role’, ’embed_url’, ‘field_value’ ‘time_period’ => 60 * 60 * 24, // integer in seconds or ‘day’, ‘month’, ‘year’ to limit to current day, month, or year respectively ‘limit_message’ => __( ‘Aha, You have completed the survey. Thank you’ ), ‘apply_limit_per_form’ => true, ‘enable_notifications’ => false
Where did I do wrong? Please advice. Thank you
Could you share a pastie of your implementation of the snippet? Based on your configuration above, I don’t think you’ve implemented this correctly. You might also try reading through these tips: https://gravitywiz.com/documentation/snippet-troubleshooting/
Hi, Is it possible to make the limit_message a shortcode from gravity view to display the view when limit is reached? I’d like to define several forms and shortcode combos.
new GW_Submission_Limit( array( ‘form_id’ => 3, ‘limit_by’ => ‘user_id’, ‘limit’ => 1, ‘time_period’ => false , // forever! ‘limit_message’ => ‘[gravityview id=”398″]’ ) );
I see this but not sure what I’d need to change there or if. function pre_render( $form ) {
( GFFormDisplay::$submission, $form[‘id’] );
Hi Chris, are you just looking for shortcode support for the “limit_message” property?
Hi David,
Thanks again a great and wonderful snippet. Is it somehow possible to limit the submission on 2 variables? I want to limit the combination of field ID 1 and field ID 2. For example, I only want 1 submission of fieldID1=1 and fieldID2=1.
Trying to make a little more sense with another example. Field ID 1 is “name” and field ID 2 is “high score”. Now I want to limit the combination no duplicates (so just 1 submission of “Robert” and high score “10”).
Does that make sense?
Thanks! Robert
Yep and this is supported. You can call this limiting by a field group:
new GW_Submission_Limit( array( ‘form_id’ => 327, ‘limit_by’ => array( ‘field_value’ ), ‘fields’ => array( 1, 2 ), ‘limit’ => 1, ‘time_period’ => false ) );
Can I request the option to have an email sent to the admin, if the limit is reached?
This is supported. Set the “enable_notifications” parameter to true. You will find a new notification event when creating a new form notification for this form.
Thanks! Much appreciated.
Hello,
Is it possible to set a global limit for the sum of all forms and for everyone?
Thank you!
Hey Christopher, we do not currently have a solution for this.
Looks promising, as soon as I paste the code, at the end of my theme’s config file, it crashes the site. I tried modifying as instructed (form id, limit_by ip, etc). Any thoughts? Do I have to purchase perks for this to work?
You do not need perks for this code to work. Try some of the troubleshooting tips here: https://gravitywiz.com/documentation/snippet-troubleshooting/
It worked! Thank you great job!
Q: In testing, I locked my self out for the day usin ip settings. Where is this being logged? how can I remove a certain IP from the list? Thanks
You can delete the entries you submitted or configure the snippet to exclude “safe IPs”: https://gist.github.com/spivurno/4024503#file-gw-gravity-forms-submission-limit-safe-ips-php
new GW_Submission_Limit( array( ‘form_id’ => 86, ‘limit’ => 1, ) );
I would like to limit several forms:
‘form_id’ => 86,77,63,102,
doesn’t work somehow. any idea?
Did you figure out how to limit several forms?
This might help: https://gravitywiz.com/documentation/apply-class-based-snippet-different-forms/
Basic Usage
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit’ => 1, ‘limit_message’ => ‘Aha! You have been limited.’ ) );
Using that makes the form disappear after submission. The “limit_message” does not show up :( Any idea?
Wow – I’m about to play with this… I’m creating a premium listing site where I want to limit the number of businesses in an area to be noncompeting. I basically want to calculate a 50-100mile radius from the business and limit the submissions to only one business , in x category, in x mile radius… Say for instances user is filling out a listing and they type their name, select category , and then they select option for how big a nocompete radius they want to purchase i.e., 25miles , 50miles, 100miles… then the next submitter who tries to purchase a listing who tries to submit a listing inside this radius with same category would get error message saying sorry – your area is locked. Please click here to receive notification when area is available.
I know this is a very detailed request but I wonder if i can acheive something similar but not exact by using the above snippet. I’m not sure how to best limit submission by radius but wonder if there might be an easier way…
Hi Nathan, this snippet won’t be much use to you. You’ll need to write some custom validation for whatever field indicates their distance. A good place to start is this filter: https://www.gravityhelp.com/documentation/article/gform_field_validation/
Hi David,
Bit of an odd one but hoping you can help. :)
Do you think it would be possible to use the above code to limit based on two fields? One of the fields being a date field.
We are selling tickets to an event and we have a limited type of each on specific days. E.g. we have 10 Standard Tickets, 20 Premium Tickets for each day shown in a datepicker.
We cannot use a stock based system as the dates could be any date in the future so this field has a great deal of permutations.
Hi Joe, our inventory snippet will actually do this with the “field_group” parameter.
https://gravitywiz.com/better-inventory-with-gravity-forms/
It’s not specifically listed but here is how you can use it:
http://pastie.org/private/o6mjf4nn2ql6tygawz5og
Thank you so much for the point but sorry I am being dense. Am unsure how to apply this to our form! :)
We have a dropdown (ID – 7) and a datepicker (ID – 6).
A specific option in the dropdown needs to be limited combined with the dates. All other options are unlimited.
This might help: http://pastie.org/private/sumhq7hof06vpflxwyarw
Sorry to keep on about this one but the issue is we do not have a quantity field so have nothing to put in the field_id column. Each submission of the form is 1 ticket. So in this case can I create a hidden field with the value of 1?
Hi Joe, yup, that’s right. Add a Hidden field to act as your quantity field.
Am so sorry to keep on, but it is only one of the options in the dropdown that I want to limit the rest can be unlimited. Guessing that is one step too far? :)
Haha, yeah… this is coming soon to GP Limit Choices which allows per choice limits but no official ETA.
Hello,
On a multisite installation how can exclude super admin from “Limit by Role” limitations?
Thanks!
Try “superadministrator” or “superadmin”.
Hi and thank you for your work on this great snippet!
I’d have two questions: 1/ is it possible to have a time period defined by two dates instead of a length? 2/ is it possible to insert $variables when configuring the snippet?
Thank you in advance for your answers and have a great day, Emilien
It is not currently possible to set the time period between to dates. Could you elaborate on #2? What do you mean by $variables?
Hi and thank you very much for this snippet! I’m having trouble customizing some configuration options. I’d need to use variables to define ‘time_period’ and ‘limit’. Here’s where I currently am:
I have a custom plugin with 2 functions : the first one returns a number of current subscriptions my users have to a product, the second one returns a time interval (difference between next_payment_date and last_payment_date)
my purpose is to limit the number of forms my users can submit, per their subscription time period and based on the amount they are charged
my problem is I can’t get the snippet to work if I set things like this:
configuration
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘user_id’, ‘time_period’ => second_function(), ‘limit’ => first_function(), ‘limit_message’ => ‘You have reached the maximum number of submissions your subscription offers’ ) );
configuration
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘user_id’, ‘time_period’ => $length, ‘limit’ => $nb, ‘limit_message’ => ‘You have reached the maximum number of submissions your subscription offers’ ) );
Thank you so much in advance for your help, have a great day, Emilien
I would actually expect that to work… Are your functions defined above the snippet?
Hi David,
Thanks for all the code/snippets/advice that you offer – amazing stuff.
Feels cheeky asking but I wondered if there was any simple way to make the time period conditional. In my situation I would like to check the user’s login info to alter the time period.
I did notice some pastie code that allowed you to check a custom field, so was thinking I could store the time period as user meta and do it that way, but I wondered if there was a way to have conditional code inside the arguments. When I tried I got error messages regarding if statements.
Thanks again – if too ‘niche’ then no worries,
Bob
Hi Bob, it is possible but not without additional custom code. You would need to override the validate() method to check if your condition was met before running the limit-based validation.
Hey there,
Very useful snippet, Is there a way to limit per week? That’s the time frame I’m needing but seems to be the only one not supported!
Thanks, Steve
Hi Steve, the snippet has been updated support limiting per week. Using “week” or “per_week” as the time period.
Hi! The counter for Limit by Role works perfect, but if I update some part of the theme (functions.php, template.php, etc) the counter no longer functions properly and the message “Aha! You have been limited” not appears. I have to delete all entries and create them again and then the counter works correctly and the message “Aha! You have been limited” appears. Where is the error for the meter to function properly? Thanks!
Regards, David
If you’re overwriting the snippet (as in, it no longer exists in your code), you would need to copy and paste the snippet back into your theme’s functions.php file. If you’re having issues where updating any theme file causes the snippet to break, there is some other conflict at play.
Hi! Is it possible to limit the submission for a specific date, entered in the form? I want users not o be able to submit lets say more than 5 per date. The will choose the date from the form.
Yup! See the “Limit by Field Value” example above. :)
Cant seem to get this to work, no matter what I do!
Trying to limit several forms by user id to once every six months. my code is the following: [quote] new GW_Submission_Limit( array( ‘form_id’ => array(‘1′,’2′,’3’ ‘limit’ => 1, ‘limit_by’ => ‘user_id’, ”time_period’ => 15778463, //six months in seconds ‘limit_message’ => ‘You already filled out this application form! Please visit the <a href=”/biuintl/portal>Applicant Portal to continue the application process. If you believe you are seeing this message in error, please contact test@email.com‘ ) );
Any suggestions? This site is supposed to go live in two days :/
Hi David, there were some formatting errors. Try this: http://pastie.org/private/bsumbdj2x96ydz88ltetia
It works after following the instructions carefully…
Glad you were able to get this working. :)
Thank you for this, it works like a charm. I was wondering if I can retrieve a value in the array in a page template? For example, I would like to retrieve the ‘limit’ value and place it in a variable in a page template.
For example, in my page template:
$attempts = GW_Submission_Limit =>limit or something similar.
Thanks again!
Sure. I assume you’re talking about a custom field or something like that. If so, you could do something like this: http://pastie.org/10778649
I appreciate your reply! My goal is to retrieve the value that is set in the ‘limit’ from the array in my page template.
What I am trying to do is basically set a conditional that if limit is = 1 then do something.
So in my page template:
$attempts = GW_Submission_Limit =>limit // where I need help :)
if($attempts = 1){ //my code }else{ //my other code }
The $attempts value is not coming from a custom field but rather from the value I set in my functions file for ‘limit’.
Thanks again!
The actual submission count is buried in the
is_limit_reached()
function. If you just want to check if the limit is reached though you can call that function after you’ve initialized the class: http://pastie.org/private/m6esloepjiw2lits9vppugHey Dan, thanks again for your time. I really appreciate it. I understand now, thats what I was looking for was that limit function. I have two more questions:
The code you provided kills my page on the if statement. I did the following:
1- I put your code in my functions file as is. Page won’t load. 2- I put the IF statement in a function so I can recall it on my template page. Same result. 3- I put all code in my template page. Same result.
I would like to mention that I put your initial snippet in a plugin I created for it so it can live outside the functions file.
Again, I appreciate your help!
Enable WP_DEBUG and see if you get a fatal error message.
Hi,
thank you for this great snippet. I’d like to ask, how to display the form when user submit.
I used your snippet with poll addons, i still need user can see the poll result after they are do submission.
currently after user submit the form, they cannot see the result. but this snippet really block multiple submission
thank you
Can you send me an export of your form and a pastie of your snippet configuration?
Hi, I am having a minor issue right now, I need to be able to limit entries by user name, this feature is working great, however I would like to be able to allow unlimited entries by the administrators of the site for demo purposes, is this possible?
Here is the basic code I think I need.
new GW_Submission_Limit( array( ‘form_id’ => 25, ‘limit’ => array(1,’broker’=>1, ’employer’=>1, ‘subscriber’=>1, ’employee’=>1), ‘limit_by’=>array(‘user_id’,’role’), ‘limit_message’ => ‘You have already filled out this form’ ) );
Thank You for your help, I’m loving the code so far.
Hi Jacob, just add a limit for the ‘administrator’ role and set it to 99999. That is essentially unlimited. Also, you only need the ‘role’ for your limit_by parameter since it automatically applies to the individual user and not the role as a group.
Any idea how to make this work with a value in a list field and make sure all values are unique in a particular column? We are trying to prevent a user from entering the same invoice number twice in the first column in a list field. The form is here https://theevictionteam.com/make-a-payment/ and the field I’m working with is field 14, column 1 (“Invoice # or Reason for payment”). Any help would be greatly appreciated! Thank you for making this awesome tool available to the community.
Hi Joel, we don’t have a solution for this currently.
Hi,
I try to limit to one submission to a form (ID 14) for users. Actually, form is only visible for registered users and i set the display of this form until 2016-03-31. I add the code to my functions.php but don’t know what to set in portion of snippet. Thanks for your help.
Hi Fabien, you’ll just need to specify the “form_id” parameter and the “limit” parameter. See the “Basic Usage” section above for an example.
Hi there, this snippet is really helpful but it does no fill 100% my needings. I’m using gravityforms with survey addon to use one survey for every post i have. As I said your snippet does the hard work of limiting the number of times a user fills a survey in different url’s but when I have a look on the results… well, all data is treated globally. Do you have snippet or idea to make the results display by post and not globally for a given survey. Thanks in advance.
Sorry, Lucas. I don’t. :(
No problem, I found a way for doing it with conditional results applying it to a hidden url field, thanks anyway!
Hello,
I’ve added the full php file to my functions file minus the starting <?php tag
I have edited the config at the bottom as follows
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘field_value’, ‘limit’ => array( // “2” is your field ID, “6” is your limit for this field ID 4 => 1 ), ‘time_period’ => 60, // forever! ‘limit_message’ => __( ‘Sorry, you have reached the submission limit for this form.’ ), ‘apply_limit_per_form’ => true, ‘enable_notifications’ => false ) );
I want to limit to 1 submission per email per day. I thought by setting it to 60 would allow me to test it if I submitted a second entry after a couple of minutes but it continues to deny me and there is no limit message appearing. Is there something I am doing wrong here?
Thanks, Paul
nevermind.. I had no duplicates enabled.. once I disabled that it is working fine now.. I even see the limit message below the fields.. thanks..
Glad you got this sorted, Paul!
Great snippet btw! I am trying to modify it slightly so that instead of using a field id it uses a field type.
As an example, I have a custom GravityForms field call my_dob that I use. When validating I usually loop through the fields in the form until I find it but for some reason I can’t access the $form variable inside this snippet.
Can you help?
Which function are you attempting to use the $form object within?
Hi, I have used this it is great but I have one query. If I have 10 forms, can I limit the form submission for 9 forms and not limit for 1 form?
Recently form_id only takes the value of form which has to be limited. Do you have certain parameter to which we pass the value of the form whose value we don’t want to limit.???
This snippet demonstrates how you can configure the snippet to exclude form IDs: http://pastie.org/private/t8ikceysoslawi9iyxlw
Hello, first thanks for the excellent snippet!
Is there a way to block the user by IP address and a field_value but display the IP restriction message first and if the user tries using a different IP as soon as the user uses the same field_value (i.e., email address) the user will see the limit message due to the email address already being used?
Configuration
new GW_Submission_Limit(array( 'form_id' => 13, 'limit' => 2, 'limit_by' => array( 'field_value', 'ip' ), 'fields' => array( '5' ), 'time_period' => 'per_month', 'limit_message' => '
Blocked!
', ));
Thanks!
This is not currently possible. :/
My form can be found here: http://www.sizeslim.com/samples
Currently I have am using this as my configuration:
new GW_Submission_Limit( array( ‘form_id’ => 2, ‘limit’ => 1, ‘limit_by’ => ip, ‘time_period’ => false, ‘limit_message’ => ‘We love that you love our products, but unfortunately you can only submit this form once!’
A few questions:
Does it block the IP at the last form page on the Paypal form? Can I add a way to block the physical address form that I have in there too?
Thank you!
Hi Kelsey, typically the same IP is used by a user for every page they access on your website (and their entire browsing session). I wasn’t clear on what you meant when you asked if you can block the physical address but I think you might be referring to the “embed_url” parameter. More details above.
Hey David,
Sorry, maybe I didn’t explain very well.
My first question in reference to my specific form was should have been: With the parameters I had used for this code I had blocked the duplicate submissions via the IP address. At what point of my form is it where that is actually applied. Is it the last page of the form? Or the beginning? I was just curious with how I have my form set up where that would actually take place.
My next question was pertaining to the address fields that I have in the second page of my form. I was asking if there was a way that I can ALSO block duplicate submissions via that paramater as well as the IP address.
A little bit of background on the form – we are offering free samples and we don’t want to end up sending out a million free samples to the same person.
Looking forward to hearing from you. And thank you!
Hi Kelsey, if the limit is 1, the user would be able to submit the form once. If they attempt to load the form again, the limit message would be displayed. You can limit by multiple identifiers (i.e. “ip” and “field_value”). This example is for a Name field. You could convert it to work for an address field as well by changing the “2.3” and “2.6” to the input IDs for each input of the Address field.
David, you are an absolute legend!
I had an issue with duplicate entries and have been trying to find the culprit for days. I couldn’t find any plugin/theme conflicts and after using the Gravity Forms logging plugin, the Gravity Forms support team seem the think users have been inadvertently refreshing the page, hence causing the dup.
Thank you so much for providing this snippet, it works very well and is pretty flexible :)
Awesome! Glad you were able to make use of this snippet. :D
Hi David,
I was wondering if there was a way to limit submision until a fixed date (i.e. until December 31st 2015), not only by a relative calendar time period (i.e. ‘per day’, ‘per month’).
Great work, and thanks!
Xavier
Hi Xavier, add this function below the snippet and then call it for the “time_period” parameter, like so:
'time_period' => gw_day_diff( '2015-12-31' )
It’s not a perfect solution. After the date is exceeded, the limit will be applied with no time period.
Hi. When inserting the snippet and saving, my page goes white… Had to edit in ftp to fix it….
Hi Nina, give this a try: https://gravitywiz.com/documentation/snippet-troubleshooting/
Hi,
I installed this code and it works perfectly, but was wondering if there was a way to have the form still visible for viewing but locked for submitting.
In our form the user selects a few choices, but sometimes wants to add or change the choices, but cant see them anymore once it is submitted.
Great code, and thanks again!
Hm, try commenting these highlighted lines out: http://pastie.org/private/nsxsrwqriiylvpzgiol3q#75-77 They are responsible for hiding the form. You should still get a validation error if they attempt to submit the form.
This is simply fantastic!
It’s not the first time I stumble upon a great Gravity Form tutorial on this website. I’ve been using the Conditional Logic with Dates method ( https://gravitywiz.com/use-gravity-forms-conditional-logic-with-dates/ ) for ages to apply limited-time discounts on my forms.
Actually, is there a way to combine these two methods? What I mean is: Say, for example, I want the sum total of purchases on a particular product that I seel through my form to be 20, but since my form is set up with a discount in a certain date range, instead of having a single field {price} I actually have two fields, {price_discount} and {price_regular}, that become available on an aut-aut basis (either the former or the latter) based on the submission date, as per the Conditional Logic with Dates tutorial.
So I’d like to have 20 total entries on {price_discount} + {price_regular}, but I don’t care how they are distrubuted (I may have 10 {price_discount} + 10 {price_regular} = 20, or I may have 2 {price_discount} + 18 {price_regular} = 20 etc. etc.).
Is there a way to do this?
Hi CC, easiest way is to use a single product field and change the price via GP Conditional Pricing. Then you can use this snippet to limit the single product field. Hope this helps.
hello, I do not know where to put the code in function.php, whether above or below, anywhere I go inside you I see a white screen (I think it is error of <? php and closing, so I wordpress problems .. .) Help!
Hi Andrea, this might help: https://gravitywiz.com/documentation/snippet-troubleshooting/
Hi David,
We are using the CoursePress theme, and every time we add the snippet to the end of the functions.php file, we get an error and have to replace it with the original functions file before the site will come back up. Here is the GW code with our usage modification. Are we doing something wrong?
https://gist.github.com/anonymous/fb11d9002071c7c400de
Hi Gary, if this is the entirety of your functions.php file, the issue is probably that you’re missing the opening <?php tag. I’d also recommend running through this doc: https://gravitywiz.com/documentation/snippet-troubleshooting/
Works perfectly. This is exactly what I was looking for. It’s a pity Gravity form doesn’t provide this functionality by default.
Thanks again!
Glad to help. Remember, a product that does everything does nothing particularly well.
Works PERFECTLY! Thank you!
Hi,
Thank you for this great code. All works great except the message configured to show if limit reached does not show the translation available for it.
I used it as follows:
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit’ => 1, ‘time_period’ => ‘per_month’, ‘limit_by’ => ‘user_id’, ‘limit_message’ => __(‘You have already submitted this month.’, “beautclick”)
I am using WPML and string translation. The string registers fine and I added a translation for it, but when viewing the page the English message still appears.
Any ideas?
Thanks.
Hi Andrei, I believe WPML has a way to register strings for translation and then a separate method for retrieving the correct string based on the selected language. This is something they’ll be better equipped to advice on. I’d love to hear their answer.
Hi David,
Indeed, you can register strings with the gettext function __(“String to be translated”, “theme-domain), as you already had in the code (line 32).
That allows for the string to be registered and a translation added.
I was able to get it working finally by modifying your code on line 76. I replaced ($this->_args[‘limit_message’] with:
__($this->_args[‘limit_message’],”theme-domain”)
So I basically just wrapped all that in the gettext function. I had found the solution here: https://wpml.org/forums/topic/how-to-translate-a-variable-in-my-theme/
Now, I didn’t check all your code to see if there is any other place where this needs to be done, but it works for my purpose.
If you could go over it all and update it as needed, I think it may help a lot of people.
Thanks again.
Hm, that seems odd. So this works:
__($this->_args[‘limit_message’],”theme-domain”)
…but this doesn’t?
Both must be present for everything to work.
So, the following line allows you to register a string for translation (and enter a translation via WPML’s String Translation interface) :
array( ‘limit_message’ => __(‘You have already submitted this month.’, “theme-domain” ) )
And this line basically allows for that translation to be fetched (otherwise it will simply return the English version):
__($this->_args[‘limit_message’],”theme-domain”)
As a side note, if you were to simply output the string directly, it would just work, but the additional wrap in the gettext function is needed because you’re calling a variable and that’s when the output actually happens.
So this would work fine, in the sense that it would automatically fetch the associated translation, if any:
__(‘You have already submitted this month.’, “theme-domain” )
Sorry, the last line of code in my previous comment should be:
echo "__(‘You have already submitted this month.’, “theme-domain” )";
(not sure how to edit the comment).
Hi Andrei, thanks for all your feedback.
This method of calling the
__()
function twice on the same string seems a little funky. WPML doesn’t know when the string is actually being output to the screen because__()
always returns the string and never outputs it. Theecho
that precedes it is what actually outputs it to the screen and WPML (which is using the “gettext” filter) would have no knowledge of the context from which__()
is being called.My gut is that this is an order of events issue. Try initializing the snippet later in the page load process, like so:
David,
I tried using the add_action as you suggested, but that seems to break the limiting. In other words, the form is no longer limited and gets display as normal.
I know it’s a little funky and indeed, gettext doesn’t know about the echo.. but I believe it’s more about context. At the time the variable (limit_message) gets initialized, WPML has no knowledge of what language you’re browsing in, so it doesn’t know it needs to set/load the limit_message in French and then pass it in French down the road.
Whereas when it comes time to echo, the wpml language variable is respected, so it knows you’re trying to display something in a certain language. Then it’s a matter of finding what the original text/string is and display the equivalent translation.
Not sure if I manage to explain clearly here. Let me know if it makes any sense.
I was able to recreate the issue where delaying the initialization failed to limit the form. Try initializing the snippet like this: http://pastie.org/private/tw86ywommpxwkailpniq
I think what is happening is that the string is being parsed by
__()
before WPML has a chance to do anything with it. By delaying the init (and therefore when the limit message variable is parsed by__()
, I think it will give WPML a chance to intercept it.Hi David, i can use this code for all my form and add some exception? i need this feature for 99 of 100 forms , but the last form? how i can unset this limitation?
Something like this should work: http://pastie.org/private/t8ikceysoslawi9iyxlw
Hi David, it works fine! Thanks so much :)
[…] else out there has done this before. I did a little search online and found this really handy PHP snippet from GravityWiz which gives you the ability to limit by IP as well as many other parameters (quoted from their […]
This is so good, thank you very much! Is there a possibility to echo counter of how much is left till reach the limit?
Hi Zane, no shortcode for this yet but we’ve started work on the perk version of this snippet which will have support for a shortcode.
One question, is it possible with this snippet to achieve this: one submission per user per url and same time 10 submissions in total per url?
It should be possible. You’ll need to configure to instances of the snippet for the same form. Something like this should do the trick:
http://pastie.org/10457455
Multiple Limiters line: ‘limit_by’ => array( ’embed_url’, ‘user_id’ ) makes wp white page and debugging shows: Parse error: syntax error, unexpected ”limit_by” (T_CONSTANT_ENCAPSED_STRING), expecting ‘)’
Just deleting the line and everything else works
Try adding a comma at the end of the line:
'limit_by' => array( 'embed_url', 'user_id' ),
Please ignore my previos comment, I was missing a coma. Cheers
yes, i was missing one on line before this one.
Awesome! Glad you got it sorted. :)
Hey David, great stuff! I had a quick question…
I’m using Gravity forms to handle registration for this free event. There is a drop down in the form, and I need each option in that drop down to have a different limit on it before it becomes disabled. For example:
Option 1 disables after 100 submissions Option 2 disables after 50 submissions Option 3 disables after 100 submissions
etc etc.
Is that possible with any of these snippets? I thought ‘Limit by Field Value’ might do it but looks like that only limits how many times a field can be used.
Thanks Patrick
Hi Patrick, it sounds like what you need is GP Limit Choices. It does exactly what you’ve described. :)
Hello,
I need to exclude some form ids to use this limit.
So instead of array ‘form_id’ => 1, I need something like “Do this” for ALL forms except the ones with ID 1,3,93.
How can I do this?
Thank you.
Hi Miguel, you could do something like this: http://pastie.org/private/slafdaprv1av00cc0q2zg#5,9-12
Include the rest of the snippet above this example. Replace the “1, 2, 3” with the form IDs you wish to exclude. Configure the new GW_Submission_Limit() bit with your desired settings.
But I think is not working. I have added this after the snipped:
[code removed]
So what I understand with this is that to all the forms when the user (all the users must be connected to send a form) is sending the form he should see that form with the limit_message. However is not happening. I still can send the same form any times.
What I think should be the correct way for this is just to check in the entries of that form if there is one of the current user and if so show the limit_message. But I don’t understand exactly how is this working.
Thank you for your fast help!
Hey Miguel, can you share your code via a pastie?
Yes sorry,
here is the complete snipped code with the config at the end.
http://pastie.org/10438597
Thank you!
This isn’t the most beautiful solution but it’ll get the job done: http://pastie.org/private/t8ikceysoslawi9iyxlw
Ok, now I think is working. I will test it for some days.
Thank you so much!!
Is there a way to configure “time_period” to work with the period of time a form is scheduled (Schedule Start/End Date/Time)?
Hi Fawn, I’m not sure I understand. Could you elaborate?
On GF settings, there is a section for Restrictions/Schedule form where you can schedule a date/time for the form to be active. What I would like to do is have it so the user can submit only 1 entry during that time period for a field that I specify. So under configuration, I would like to set ‘time_period’ to that period of time that the form is active. I have it set for per month right now. This is what I have:
new GW_Submission_Limit( array( ‘form_id’ => 2, ‘limit_by’ => ‘field_value’, ‘limit’ => array( // “26” is field ID for reviewee, “1” is limit for this field ID 26 => 1 ), ‘limit_message’ => ‘You have already submitted a review this month for this employee. You can only submit 1 review per employee per reporting period.’, ‘time_period’ => per_month // set to false for forever!
Hi Fawn, currently there is no simple way to achieve this. The snippet does not support limiting between two specific dates, only a time range. I’ve added this to the list of features for the upcoming plugin version of this snippet.
Awesome class, thanks a billion!
Glad you like it!
This code was a major life saver so thank you for posting this. However, after the gravity forms latest update, this code no longer works to limit submissions. They all still appear. I am sure you are aware of this issue but I wanted to post this in case you are not. If you would like to see the page, I will have to create a new one as the current forms are behind the login. Let me know if you would like me to do this.
Hi Emily, I’ve just tested this locally and appears to still be working. Could you share how you have your form configured?
Need Some Help. I have used this configuration for a gravity form I am using
class GWSubmissionLimit extends GW_Submission_Limit { }
Configuration
Basic Usage
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘time_period’ => ‘per_month’, ‘limit’ => 1, ‘limit_by’ => ‘role’, ‘limit’ => array( ‘administrator’ => 20, ‘contributor’ => 2, ‘subscriber’ => 1 ), ‘limit_message’ => ‘You have already submitted the report for this month. You can only submit the form once in a month.’ ) );
With this the subscriber can submit the form once, now I want to know whether limiting by per month means. Does it mean the counter will reset every month or will it reset exactly a month from the day the person submitted the form. I need the first option whereby the counter resets 1st of every month, but the subscriber can fill it only once. Can this be done? Loved the snippet, Thanks
Any way to also include a shortcode after the limit message?
Hi Jeff, just updated the snippet to add support for this. :)
Hi, I’d love to use this from now on. I will have a lot of forms and checking a box (or two) in the form settings would be much more comfortable than editing the functions.php each time. Is there a chance to have this feature as an installable perk in the near future? Flo
This will be converted (and enhanced) to a perk; however, it’s several months off. It’ll be worth the wait!
A lot of +1 to perk format
It’s coming, Leho! We’ve got a big perk in the works and this one is next in the queue. :)
Hi,
just some thoughts what will be on “Limit by FIeld Value ” if the form have conditional logic. For example: If one have a dropdown with two options A & B. When an user selects A the form loads field Aa, if he chooses B the form loads field Bb.
So exactly the fields Aa & Bb should limit the form to be submitted more than once.
I understand that for a single field limit array 2 => 6 works but what happens if there are 2-3 fields that an user switches between.
Todor
If you provide multiple fields, it will treat them as a “group”. Only when all fields have the same value as previous submission will the limit be enforced. For example, if you specified a Name field and an Address field to be limited together, only when the same name and same address are provided will this count towards the limit.
Hello David and thanks for the quick reply. What I mean is not grouping fields but based on conditional logic limitation. For example:
Dropdown > Option A / Option B If chosen Option A then text field A is shown – this is let
s say arrey1 If chosen Option B then text field B is shown - this is let
s say arrey2.When I add code: limit_array 1=>1 it works for field A but not for field B because there isn`t code that points to it.
So I tried to add for field B array2 but it isn`t working. And i am curious if it is possible to add one more field .. something like: 1=>1, 2=>1
Regards, Todor
Hi Todor, currently they only work as a group. It doesn’t support conditional logic in the way you described.
[…] I am following this DIY code by GravityWiz but the author doesn’t mention how to make the code work with 30 minutes, 1 hour, 2 hours, etc…? He only explains how to make it work with 24 hours – https://gravitywiz.com/better-limit-submission-per-time-period-by-user-or-ip/ […]
If the default time_period is 24 hours, how do we make it so its by 30 minutes? On top, it says we can do it by minutes but doesn’t explain how.
Hi Jason, I’ve updated the “time_period” parameter description above and including the addition here:
30 minutes would be “60 * 30” or “1800”.
Hello, great code.
How can I put that if the user role is “example_2” count as 2 people in the limit form instead of 1?
So if the limit of entries in that form is for example 15 and a user with user role “example_2” send the form the amount available must change to 13 (-2) (instead of 14 (-1) that is the normal way).
I need to know where in the code execute the subtract to make this conditional.
Thank you!
Hi Miguel, this is somewhat involved. I’d recommend hiring a developer to assist with this customization.
The limit_by role is not working in my case:
Basic Usage
new GW_Submission_Limit( array( 'limit_by' => 'role', 'limit' => array( 'fanpass' => 1, 'fan-pass-2' => 1, 'administrator' => 1 ), 'time_period' => false, 'limit_message' => 'Enviado' ) );
I have this code added so I understand that users with roles fanpass, fanpass-2 or admin can send the form only 1 time (each form).
In my website I have two forms with PayPal that register my users that doesn’t have any limit/is not necessary to be logged in and one of them I see the text “Enviado” even if is don’t sent.
What I understand with the limit_by role is that ONLY in the forms that i have ticked: “User must be connected” the limit is activated. I can’t include the “form_id” part here because we are going to create a lot of forms so if I add this limit only to those new forms I would need to change the code each time.
So, I just need this limit to all my forms which my users must be connected to use them.
Any idea of how can I solve this?
Thank you!
Hi Miguel, the snippet does not only apply when the require user to be logged in option is checked. That would be a nice enhancement.
In the meantime, you can apply it to multiple forms more readily in the code like so:
https://gravitywiz.com/documentation/apply-class-based-snippet-different-forms/
Hello,
thanks that works for me to set the forms I need. However I still have problems with the limit that is not working correctly with my site I dont know why:
This is now my configuration:
Basic Usage
foreach( array( 4, 5 ) as $form_id ) { new GW_Submission_Limit( array( 'form_id' => $form_id, 'limit_by' => 'role', 'limit' => array( 'administrator' => 999, 'fanpass' => 1, 'fan-pass-2' => 1 ), 'time_period' => false, 'limit_message' => '
Apuntado
' ) ); }
And I send the form with my account (admin) without any problem and then I see the limit message. However the limit is not correctly set because I have deleted all the entries in that form and I still see the limit message (even if I change the limit number to 999). I understand that if I delete the entries of the form I should see the input button again working instead of the limit_message.
I have tried to clear cache of my browser but still not working. I need that if the form is sent the user must see the limit_message (ok) but If we delete that entry of the form, the user should be able to re-sent that form because we have deleted the entry.
Any idea? Thank you!!!
Some things to check on:
Hi! When I place this code in my theme’s functions.php file the site will not load.
new GW_Submission_Limit( array( ‘form_id’ => 2, ‘limit_by’ => ‘user_id’, ‘limit’ => 1, ‘time_period’ => ‘per_day’ ) );
I tried removing the ?> at the end of the file but that didn’t work either. Can you help? I have the latest version of gravity forms installed.
Hi Joe, here are some common issues people run into when installing snippets: https://gravitywiz.com/documentation/snippet-troubleshooting/
Thank you for the code, it was right on the money for me!
Awesome! Glad to help. :)
I like the extendability of this snippet. I was wondering if there was a way to limit after a certain event has occurred. For example, I have them fill out a gravity form and then that accesses a screen where they fill out more information. I don’t want to block them if they leave the second screen, but I do want to stop them from entering information on the first screen if they fill out the second screen.
Thanks,
Scott
Hi Scott, your comment got lost. Sorry, about that. There are two ways to accomplish this. Both require custom code. If the user is not logged in, you’ll need to use cookies to remember their progress. If the user is logged in, you can store their progress in the user meta.
Hi guys ! Thanks for this awesome tutorial. I’m making a contest site, I used it in order to allow members to post a CPT only one time. But do you know if with this plugin I can allow members to edit the CPT they posted ? Best Regards Damien
This plugin should do the trick: https://github.com/jupitercow/gravity-forms-post-updates
Hello, Thank you very much for your snippet. I have a question : I’ve tested some usages limitations with a test user. Is there a way to clear his history ? I’ve deleted recorded messages, but the limitation is still active. TY !
Hi Fred, I’ve just updated the snippet to resolve this issue. :)
Thank you very much, you’re awesome !
Hi,
You guys are just superb!!, i am having one problem, i am trying to pass three fields with different ID’s with limit to 1 in one day.. below is my code.. but its not working.. is this the right way.. please help!!
THanks..
new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘field_value’, ‘limit’ => array( // “2” is your field ID, “6” is your limit for this field ID 24 => 1, 25 => 1, 26 => 1 ),
) );
I tried the same code on my end (replacing only the form ID and field IDs) and it worked as expected. Only thing I can think is maybe the snippet is not installed correctly. This might help: https://gravitywiz.com/documentation/snippet-troubleshooting/
Thanks for the reply..
Strange its working with 1 id, but not working with multiple ids.
Ok let me check again.. another quick questions..
let say i am using one field to limit to 1. On form load, is there any wat that the field is in disable mode or with some red color after its reaches the limit..
Once again thanks…
Hi Irfan, removing or disabling the choice when the limit is exhausted is supported with GP Limit Choices. I think based on what you’re trying to do, the plugin will be a lot easier to use and the snippet I shared with you will allow you to apply the daily limit. I’m not just trying to upsell you. I really do think it’s the best choice for this functionality. :)
For some, I added this code to my Functions.php
It breaks my site…blank screen. I only made the following changes to the code
new GW_Submission_Limit( array( ‘form_id’ => 3, ‘limit’ => 1, ‘limit_message’ => ‘Please try again in 24 hours’ ‘limit_by’ => ip, ‘time_period’ => ‘per_day’ ) );
Any ideas? I removed the opening <?php> tag. There is no closing tag. Sorry…I am not a php master and I can’t see the issue.
This article has a bunch of tips for installing snippets and common issues: https://gravitywiz.com/documentation/snippet-troubleshooting/
This code won’t work for me under a certain condition. I am actually embedding 7 forms in one page for a voting mechanism (and, yes, I have problems with the wisdom of this too, but not something I can change at the moment). Unfortunately, I’m up against finding a solution for this today.
The goal is to restrict users by IP to voting on each contest only once, so that I’d only get the restriction notification on the form(s) I already voted on, if I came back to the page to vote again in the timeframe. For testing purposes, I’m only setting a limit on one of the forms. However, when I test that form, it applies the restrictions to all the others.
In other words, if I test vote on any of the forms I haven’t specified, I don’t get any restrictions, as expected. When I test vote the one I have restricted (id=8), it stops me from voting on any of them, so it’s not respecting the form ID. I have it set to 120 seconds so I can test easily repeatedly.
Originally, I wanted to use an array of form IDs, but that doesn’t appear to be supported. However, at present, I can’t even set limits to more than one form, since once the first one is submitted, it’s blocking all of them.
These are my usage parameters:
new GW_Submission_Limit( array( 'form_id' => 8, 'limit_by' => 'ip', 'limit' => 1, 'time_period' => 120, 'limit_message' => 'It appears you have already submitted this form. Only one vote is allowed per contest.' ) );
Hi James, I’ve just updated the snippet so only the form that is limited should be configured. You will still need to provide individual configurations for each form you wish to limit.
Thanks for the quick update David. Since I had to get client signoff I was forced to break things into separate forms this time, but can definitely see other times when this will be a useful update. I noticed some of your other snippets do allow form ID arrays. That would be really useful and keep the code size down.
I’m really surprised that form submission limit by IP isn’t a feature built into GF. It’s a fairly glaring gap.
This would be an awesome little plugin!
I completely agree! It’s in the works. ;)
Hello David
We have a question about Snippet Limit submissions The product we sell through gravity forms are seminars and the product choices are the different dates the seminars are held. And according to the date of the seminar, the number of available seats changes (different meeting rooms). How exactly can we limit submissions per product choice?
Thanks in advice for your help,
Femke
Hi Femke, check out my plugin GP Limit Choices (part of the Gravity Perks package). It sounds like a perfect fit. :)
Does this limit by ip of the individual computer or by the outbound modem ip. In a company could each computer do it once or only one person in the company behind the modem?
Hi Patrick, this is based on the public IP which typically is the same for any devices connecting to the Internet through the same modem. So within a company, limiting by IP with this snippet, would not be very usable.
Awesome Snippet! Just wanted to verify, if I wanted to limit submission to one a day per logged in user, I would do the following:
new GW_Submission_Limit( array( 'form_id' => 3, 'limit' => 1, 'time_period' => 'per_month', 'limit_by' => 'user_id', ) );
Almost. Just change the
time_period
from “per_month” to “per_day”.Hello,
I’m using wordpress 3.3.2 and Gravity Forms 1.6.5 and I can’t update them right now.
I need a code that makes this function on my site:
“Limit the number of a submissions a logged in user can make to specific form from the same embed URL. This would allow you to embed the same form on multiple pages and allow users to submit that form up to the submission limit on each page.”
This code (valid if wordpres and Gravity Forms are updated) breaks my site:
new GW_Submission_Limit( array( ‘form_id’ => 2, ‘limit’ => 1, ‘limit_message’ => ‘Aha! You have been limited.’, ‘limit_by’ => array( ’embed_url’, ‘user_id’ ) ) );
Is there a way to do it? I would pay for this job.
Thank you, Sabbella
Hello,
I’m using wordpress 3.3.2 and Gravity Forms 1.6.5 and I can’t update right now. I need this code -or another- that makes this function on my site:
“Limit the number of a submissions a logged in user can make to specific form from the same embed URL. This would allow you to embed the same form on multiple pages and allow users to submit that form up to the submission limit on each page.”
new GW_Submission_Limit( array( ‘form_id’ => 2, ‘limit’ => 1, ‘limit_message’ => ‘Aha! You have been limited.’, ‘limit_by’ => array( ’embed_url’, ‘user_id’ ) ) );
Is there a way to do this? I would pay for this job.
Thank you, Sabbella
I’m looking for a little more than the snippets listed. I’m trying to limit the submissions to only 4 per person. There may be more people at the same IP Address, so that cannot be used as a delimiter. Is there a way to adapt this snippet to do the following:
If Last Name field matches any of the last names already entered, and the First Name field matches any of the first name fields entered, and the Zip code field matches any of the zip code fields, on the 5th time these all match, deliver an error message.
This is possible with custom code. Get in touch for a quote.
Nice script. Is it possible to include different IDs in form_id ?
You’ll want to create a new instances for each form (example).
Is there a simple method to redirect to a URL after limiting entries? Would love to redirect to a URL instead of displaying text message.
Thanks. bg
No method currently but I’d be happy to add one if you’re interested in commissioning the custom code. Get in touch.
As always you are the Gravity MutsNuts dude on this!
Not 100% sure what MutsNuts are… but thank you? :D
This does not work! It was even recommended by the developers of Gravity Forms.
Keep getting an inclusion error in functions.php
Fatal error: Class 'GWSubmissionLimit' not found
Hi Chris, are you including the full snippet? Are you removing the opening <?php tag from the snippet if your theme’s functions.php already has an opening <?php tag?
I am getting the same issue.
Hi Alicia, I’ve sent you an email requesting some additional information.
I tried adding this snippet to function.php but its not working, the site goes blank.
Hi Raees, try these troubleshooting steps:
https://gravitywiz.com/documentation/snippet-troubleshooting/
Well, after lots of fiddling around and customizing this snippet (thank in advance, by the way) it seems that we’re close to a solution, but stuck. Here’s the situation:
Problem 1: We need a way to better limit the Gravity Form Polls by IP ADDRESS (instead of just cookie). We also use other Gravity forms on our site that aren’t Polls (Contact Form, etc.) so a blanket limitation of all Forms isn’t possible….and we’re regularly adding new Polls, so it doesn’t make sense to rely on manually adding Form IDs to what needs the User Limit applied or not.
Solution to Problem 1 and Problem 2: We solved this by modifying the snippet to check if a Form is of “type=poll” first, before applying the IP limitation and all is working well EXCEPT that now, once you’ve voted on a Poll, you cannot see the results again when you return to that page.
Problem 2 Solution: Here’s where we’re stuck…we need a way to still see the Poll RESULTS after a Gravity Form Poll has been submitted and is now being limited by the snippet.
Anyone? We’re a pretty savvy group here but stuck scratching our heads on this one and beginning to wonder if it is even possible. Happy to post code somewhere, but I hesitated to do so yet, figuring that we were still in the “is there a way around that?” phase with this second issue.
Thanks in advance.
Can’t get this to work. cut and past exactly as above. WP version 3.9. GF version 1.8.8
Any thoughts on what to check? Thank you!
Can you provide a URL to the form and a pastie with the contents of your functions.php file?
I’m running s2 member pro and I’m trying to figure out a way to make it so that one user level can submit 1 form 3 times in a 30 day period of time and another user level can submit 6 times etc.
Is there a way for it to limit by role as well as user id?
Basically I’m trying to have it so that users purchase their monthly subscription level that gives them the ability to submit content x many times per month, but trying to figure out the best way to go about that.
Hi Mel, this snippet is definitely on the right track but unfortunately does not provide the ability to limit by user role. If it did, it sounds like this would be a great fit for your needs. If you’re interested in commissioning this enhancement, get in touch.
Will do. I just sent you an email. Thanks!
Did you manage to find a solution for this?
I have a similar situation, just using Groups plugin instead of s2member.
Thankful for any help! :)
Hi Johan, yep, limiting by role is now supported. Search on this page for the “Limit by Role” section.
Hey, really helpful snippet of code.
Is it possible to limit the total number of submissions that can be made on all (combined) forms?
ie. total limit is 20 and that includes submissions on multiple form ID’s?
I wrote a customization that handles this here: https://gist.github.com/spivurno/6399284
That code doesn’t seem to work properly I’m afraid.
Change the time to 60 seconds and my post form ID’s.
It gives the message on the script that you’re all maxed out, but the form remains in place and I’m able to continue posting.
The code above however, works fine for single forms.
Oh I should add, latest version of GF and WordPress incase you want to debug it if you’re using it on any production sites.
I am using the Saved form plugin for WordPress 3.9 https://github.com/soulseekah/Gravity-Forms-Saved-Forms-Addon.
The two are conflicting. If I set the limit of your code to 1 time then when I return, it is telling me my limit has been reached.
Do you know how I might resolve this. Thanks for this great contribution. I used it when I was using the Gravity Forms Data Persistence Add-On and it worked great. That plugin however is not working since WordPress update.
Hi Midway, wish I had time to dig into this. If you’d like to commission me, you can reach me here.
Thank you for this! This was very useful for a project I’m working on.
Glad you found this useful! :)
Any idea what you would do for this on a ‘network’ (aka multisite) installation?
Hey there first of all thanks for this code… it’s exactly what I was looking for.
Is it possible to limit by ID and something like User Role? I use S2member and what i’d like to do is have it so that a user id within member level 1 can submit 3 forms per 30 days and a user id within member level 2 can submit 6 forms per 30 days.
With the above code I know I can do it by the ID but not sure how I would also incorporate the user role into it.
Any ideas?
Is it possible to place different parameters on multiple forms? To limit form 1 to 5 submissions and form 2 to 10?
Hi Ben, yes, you can create a separate limit per form:
new GWSubmissionLimit(array( 'form_id' => 1, 'limit' => 5, ));
new GWSubmissionLimit(array( 'form_id' => 2, 'limit' => 10, ));
You’d just add both to your functions.php with the snippet.
This great, but does it only work for gravity? I have been looking for a way to limit visitors comments to one per post. I have been successful doing it for login users with the following code:
'Signez cette Pétition')); } else { $usercomment = get_comments(array('user_id' => $current_user->ID, 'post_id'=>$post->ID) ); if($usercomment) { echo '
Vous avez déjà signé cette pétition. S\'il vous plaît partager avec votre famille et vos amis
'; } else { comment_form(array( 'title_reply' => 'Signez cette Pétition', 'title_reply_to' => 'Leave a Reply to %s', 'comment' => 'Pourquoi signez-vous? (optionnel)', 'cancel_reply_link' => __( 'Cancel reply' ), 'label_submit' => __( 'Signer >' ), 'comment_notes_after' => '', )); } ?>It works when the comment_form() is replaced with the above code. However, I will love to do it for visitors (! is_user_logging). I guess if I find a way to verify their email it might be useful. Please let me know if you have any idea or how your code can be modify. Thanks.
//check if user has previously commented the post. global $current_user, $post; if ( !is_user_logged_in() ) { comment_form(array(‘title_reply’=>’Signez cette Pétition’)); } else { $usercomment = get_comments(array(‘user_id’ => $current_user->ID, ‘post_id’=>$post->ID) ); if($usercomment) { echo ‘
Vous avez déjà signé cette pétition. S\’il vous plaît partager avec votre famille et vos amis
‘;
Is there a way to use this code on 2 different forms on the same site, presenting a different message on each form if limit is reached.
i.e. something like
new GWSubmissionLimit(array(
Hi, David!
I’m having an issue. I have 4 forms on one page, form_id=1 to form_id=4. All four forms are affected by the limit=1 constraint I set on form_id=1 (the other three forms do not have their own filters, only one GWSubmissionLimit instance was created in functions.php, referencing only form_id=1).
When I submit the first form, all four display the limit message.
Do you have an idea what’s going on?
Thanks, Ivan
I’m wondering if there is the ability to restrict the submissions by email. What I want to do is set it so that the form is limited to 1 submission per email address per day. Is this possible?
Hi Jordan, currently this snippet does not support limiting by a field value. I’d be happy to add support for this if you’d like to commission the functionality. Just get in touch at david at gravitywiz dot com.
Is there a way to allow a certain IP or IP block for testing?
To test, I typically just set the limit to one and submit the form myself. You should be blocked or allowed as your settings specify.
Hi! Sorry for reviving this old thread but I’m using GF 1.8.3 (latest) and I get a fatal error when trying to add this great snippet. Fatal error: Class ‘GWSubmissionLimit’ not found
Have been that class replaced on new versions?
Thanks for all, I really need this snippet working!!!
Hi Jaypee, it sounds like the snippet has not been copy and pasted in it’s entirety. The snippet defines the GWSubmissionLimit class and the very bottom you instantiate it (aka, start the engine) for the class. If you’re still having issues, feel free to email me a copy of your theme’s functions.php file where you’ve pasted this snippet (including the snippet as you have it in the file). david at gravitywiz dot com.
Hi David, thanks for your quick answer and yes, I missed a portion of the code :/ I’m sorry for that.
One question though: I have a form that I’m using to have users on a site apply to a job post. On this form I have two fields one takes the user ID and the other field is a cover letter, only cover letter is visible to the user, user id is a hidden field.
On the form submission, using the
gform_after_submission
hook I add entries to a repeater field from advanced custom fields.The hook is very simple and looks like this:
add_action("gform_after_submission_5", "acf_post_submission", 10, 2);
function acf_post_submission ($entry, $form) { $field_key = 'field_52fae7b9b229c'; $post_id = $entry["post_id"]; $value = get_field($field_key, $post_id); $value[] = array('app_id' => $entry[3],'app_cover' => $entry[2]); update_field($field_key, $value, $post_id); }
The issue I’m having is how to prevent that the same user_id submit this form on that $post_id, but at the same time allow to be submitted on another $post_id where user never submitted :). Considering that the form id I’m using is always 5.
I thought maybe with some tweaks of this code I can achieve this.
The “no duplicates” checkbox on form editor is not working at all.
Thank you so much if you can guide me to find an answer.
It sounds like you want limit by a combination of factors: the URL on which the form is being submitted from and also the ID of the logged in user. Is that right?
If so, you can provide multiple “limit_by” parameters. For example:
'limit_by' => array('embed_url', 'user_id')
. I think this should do what you need.Great! I will check it right away. Thanks so much for such a fast answer!!
hi, its really useful for me, i search more for a plugin to make multi question poll in my site, and i found your article here. but can we make an shourtcode or a form click to check, if a form is checked or have that shortcode then we can make it limmit. sry for my bad english :)
Could you give more details on what you want to accomplish?
Thanks for this snippet, worked a treat and did exactly what I wanted. Cheers Paul
Glad to hear it, Paul. :)
Hey there. Amazing snippet for GF! I’ve been having troubles finding the right way of installing/modifying this snippet the way I want it to work. I’m able to submit entries but I must of done something wrong as it’s not limiting myself (hopefully the IP? because visitors don’t have to sign up, so I need it to limit their IP’s and possibly their cookies as well? How would I do that in this?) to the 2 entries allowed. I’ve made a snippet on that Snippi website, so if you wouldn’t mind taking a look at it that would be great! Thanks! http://snippi.com/s/54nch8y
I figured it out with another snippet you had linked to this post!
Hi,
Is it possible to only show the message without really limiting the submissions.
Kind regards
I have a situation where I’d like to apply a different submission limit to different users.
Is there an easy way to change ‘limit’ => 2, to instead something like ‘limit’ => [value of custom user field],
Where the user field is a table in the database with content that varies based on the type of user? I know there are plugins to handle user meta; I wonder if I can tie that in with this snippet, so that some of my users can submit a form 20 times a month, whereas others can submit the same form 30 times a month, depending on the value of that user meta attached to their profile.
Hey Thank you!
i’ve edited this plugin to make it display custom page to the user when limit is reached.
if anyone want to make something like follow this steps:
http://pastebin.com/nKuJtVCs
the page will be displayed to the user instead a simple message
Hey Thank you!
i’ve also edited this plugin to make it disaplay custom post when limit is reached.
if anyone want to make something like that:
replace line 39 with add_filter(‘gform_get_form_filter’, array($this, ‘output_message’) );
And add a new function inside the class: function output_message() { $GWpage = get_page_by_title( ‘The Page Title’ ); $GWpost = get_post($GWpage->ID); $GWcontent = $GWpost->post_content; return apply_filters(‘the_content’, $GWcontent); }
the page will be displayed to the user instead a simple message
Love the ability to limit it to a user id!!! However, once the limit is hit I can not even display the results of the poll. Is there anyway to edit the above code to allow for the results to still be displayed? Thanks for the code snippet, it is a great addition to the polls add-on.
Never mind, I did some more digging and found I was using the wrong shortcode… Thanks again for a great snippet of code…
For anybody else looking for the same answer:
[gravityform id="11" action="polls" mode="results"]
Good stuff! Thanks for sharing. :)
Great, thanks for the effort on this. I have two questions:
1) Once voted, it hides the entire form, is there a way to still allow the user to see the results of the poll?
2) I have setup GF so that the user can add as many polls as they want via the WordPress backend, so limiting them by choosing the form ID is difficult. I also have other forms on my site that I don’t want to limit. Is there a way I can limit the forms within a specific div?
Thanks again.
p.s This seems a very sensible request and fix, do you think it will be incorporated into the final GF poll code?
Hi Rob,
You might consider using the built-in “Block repeat voting via cookie” option that comes with the polls add-on. If this is not an option, let me know and I’ll dig a little deeper into making this snippet play nicer with the Polls add-on.
Thanks, I actually found the documentation (its quite hidden!!) for it… I thought it would’ve been something that was built in… turns out it was. Thanks anyways.
Well Rob, care to share with the rest of us what that variable is we need to change in order to allow users to still see the results but prevent them from voting again?
Hi, wasn’t sure about something. Could i limit the number of submissions per user and over a time period.
I.E. Each user can submit the form 8 times in a month. At the end of the month they can submit the form another 8 times.
Sorry, probably a dumb question but i wasn’t quite sure.
Everything is working fine, however, it is restricting the IP to only one entry per day, not email. How do I change it so it only limits emails to one entry per day?
Also, once I have entered the contest, I can’t see any of the content on my contest page. It only shows the “limit_message”. Is there a way to redirect a specific URL once the limit has been reached instead of just outputting text?
Thanks!
I am trying to implement this with a genesis child theme, but I’m getting the white screen of death when I add the code to my functions.php file. Am I missing something?
Hi David, Great feature – this is a must that has to be integrated to every form. I tried copying your snippet to my theme’s function.php file at the very end just before the ?> It shows errors while i load my page and the particular line is
add_filter(‘gform_get_form_filter’, create_function(”, ‘return ‘
{$this->_args[‘limit_message’]}
‘;) );
Can you please help me in this regard. do i have to change any of the hooks from gravity forms itself. thanks so much, ~ sangram *PS: i desperately need this snippet working on my site. you can PM me personally if you need login access.
[…] Nice little code snippet that makes it so a user can only submit a form every X hours/minutes. Potentially very handy for contesting. […]
Everything is working nicely on my website except for one aspect: when someone exceeds their limit, it is blocking them from accessing all of my forms, not just the one I’ve specified in ‘form_id’
The only unique thing about my website that perhaps makes me different from your average user is that all of my forms are embedded on the same page.
I’m using the following options: new GWSubmissionLimit(array( ‘form_id’ => 21, ‘limit’ => 4, ‘time_period’ => 60 * 60 * 24, ‘limit_message’ => ‘Sorry! You have reached the maximum number of submissions allowed in a 24 hour period.’, ‘limit_by’ => ‘ip’, ));
Thanks for your work on this!
Hi Erik,
In GF 1.7 the “gform_get_form_filter” hook has been enhanced to pass the form object as well allowing you to only filter a specific form’s output. In the meantime you’ll need to make this modification to the core of Gravity Forms and then also make a small change to the snippet. I’ve included both changes below.
GF Core Change http://pastie.org/5594871
GW Snippet Change http://pastie.org/5594855
Just wanted to thank you for taking the time to provide this code, It works very well and is something I’ve been looking to do for some time now. so thank you.
Glad to hear it! Thanks for the kinds words. :)
Thank you so much for sharing this post! I was looking for this for past two hours and looks like I’ve found what I wanted! :D
Just one question though, is there a way to count the number of submission within the time period? How can I echo out the number of submissions made, so that I can display the user with a message saying, “You now have x number of submissions to make for the day”
Can you enlighten me please?
Hi Sam,
There is not simple method with this particular snippet to output the number of submissions made; however, that data is retrieved as part of this snippet. You could retrieve it again and output it with the gform_pre_render hook. If you take a look at the “is_limit_reached()” function in this snippet, you will see that the [code]$entry_count[/code] is retrieved.
eternal thnks <3
u are a real wizard
OMG thanks so much, this saved my proyect.
but i am a little confused with some things:
1-what would be the numbre ecuation for setting a 24 hours limit? ‘time_period’ => (?)
2-can i set the limit BOTH to user id AND ip? i am interested in anonymous being able to post on my blog, but only once a day.
i aprreaciate any help or guidance :)
1) 24 hours would be
'time_period' => 60 * 60 * 24
2) You should be able to simply create a second instance of the class with the “limit_by” parameter set to “User ID” (assuming the first instance is set to “IP”): http://snippi.com/s/wj13nis
One observation: when I delete entries within the time_period, the user can once again submit the form. Is this expected behavior?
Ideally, I would like to be able to delete entries without resetting the user’s/ip’s quota.
Hi Jon, this functionality is bound to the entries. I don’t currently have plans to support a non-entries based solution but feel free to hire me if this is something you need. :)
I figured out the problem. A single quote in my limit_message. My fault.
I must be missing something. When I put your snippet in my theme’s functions.php ( before the ?> ), my site becomes a blank page. Any ideas?
does anyone know if i can use this code in wordpress? if not, any alternatives for WP??? thnks :)
This code is for Gravity Forms which runs on WordPress.
I’m curious about this snippet. I have forms that a customer is only allowed to fill out once every two years. That being said, I have two quick questions.
1: Would I just use ‘1051200’ as the time, since that would equal 2 years (give or take a day on a leap year).
2: If 8 of my forms would require this, would I have to rewrite this entire script for each instance (form), or can I add an array for the form ids like this…
‘form_id’ => 7,9,10,14,18,19,23,47
Thanks in advance. I appreciate all your hard work that you’ve put into this snippet.
Here is how you could apply the same functionality to multiple forms quickly: http://snippi.com/s/rq91q50
The “class” portion of the snippet only needs to be included once. Then you can initialize it multiple times for different forms.
very good ;)