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