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.

								There's a better way.
							<p>This snippet is <b>available as a plugin</b> with Gravity Perks, a suite of <i>over 47</i> premium Gravity Forms plugins!</p>

View Plugin Buy Gravity Perks

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?

  1. Gravity Forms v1.8 is required to use this snippet.
  2. Copy and paste the snippet into your theme’s functions.php file.
  3. Modify the “Configuration” portion of the snippet (at the very bottom of the code) to meet your needs. Full usage instructions are below.


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!
) );


  • 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 as false 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 of

  • time_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 the limit 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 of 60 * 60 (or 3600) 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 address
    • user_id: limit by the logged in user’s WordPress user ID
    • embed_url: limit submissions of a form from a specific embed URL
    • role: 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.


  1. Frank P
    Frank P April 12, 2024 at 8:23 am

    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.

    1. Samuel Bassah
      Samuel Bassah Staff April 12, 2024 at 9:27 am

      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.


    1. Scott Ryer
      Scott Ryer Staff August 10, 2023 at 3:06 pm

      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' ) ) );

  2. claudio
    claudio April 22, 2023 at 8:57 am

    Is there a way to allow users to “buy” more submission limit sold as a woocommerce product, and update the user’s limit amount?

    1. Scott Ryer
      Scott Ryer Staff April 24, 2023 at 10:52 am

      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.

  3. Chris Wharton
    Chris Wharton November 3, 2022 at 1:40 pm

    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,


    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!

    ‘ ) );

    1. Scott Ryer
      Scott Ryer Staff November 3, 2022 at 3:12 pm

      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.

  4. unitar
    unitar June 13, 2022 at 2:36 am

    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?


    1. Samuel Bassah
      Samuel Bassah Staff June 13, 2022 at 8:19 am


      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.


  5. Joe
    Joe June 8, 2022 at 7:39 am

    Hey guys, thanks for the great snippet.

    I have two questions.

    1. 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…”.

    2. 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.



    1. Samuel Bassah
      Samuel Bassah Staff June 8, 2022 at 8:27 am

      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.


  6. Solomon
    Solomon May 26, 2022 at 2:42 pm

    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?

  7. lemon lin
    lemon lin October 4, 2021 at 4:19 am

    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

  8. Luigi
    Luigi April 28, 2021 at 12:11 pm

    Hi, can some one help me to change code to get unlimited number of submissions using “-1” value in “by role” mode?

    1. Dario Space
      Dario Space April 28, 2021 at 12:16 pm

      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 ) );

  9. Kiel
    Kiel March 24, 2021 at 3:05 pm

    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.

    1. Scott Ryer
      Scott Ryer Staff March 24, 2021 at 4:09 pm

      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.

  10. Sietse
    Sietse January 14, 2021 at 5:33 am


    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.

    What am I missing?

    1. Ryan Donovan
      Ryan Donovan January 14, 2021 at 10:41 am

      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!

  11. Julie
    Julie January 11, 2021 at 2:27 pm

    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’ ) );

    1. Samuel Bassah
      Samuel Bassah Staff January 12, 2021 at 5:29 am

      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' ) );

    2. Julie
      Julie January 15, 2021 at 6:23 pm

      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.’ ) ) );

    3. Samuel Bassah
      Samuel Bassah Staff January 16, 2021 at 12:28 am

      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.' ) ) );

    1. Ryan Donovan
      Ryan Donovan January 8, 2021 at 1:50 pm

      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!

  12. Faiz
    Faiz October 8, 2020 at 12:21 pm

    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?

    1. Samuel Bassah
      Samuel Bassah Staff October 8, 2020 at 1:49 pm

      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.


  13. Adam
    Adam July 27, 2020 at 5:24 pm

    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?

    1. Samuel Bassah
      Samuel Bassah Staff July 28, 2020 at 7:08 am

      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.


  14. Craig
    Craig June 24, 2020 at 4:50 pm

    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.

    1. Scott Ryer
      Scott Ryer Staff June 24, 2020 at 5:06 pm

      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 the time_period you want to limit on.

    2. Craig
      Craig June 24, 2020 at 5:21 pm

      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.

    3. Ryan Donovan
      Ryan Donovan June 24, 2020 at 5:32 pm

      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.

  15. tobi
    tobi June 23, 2020 at 10:18 am

    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?

    1. Ryan Donovan
      Ryan Donovan June 23, 2020 at 11:01 am

      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!

    2. tobi
      tobi June 23, 2020 at 1:01 pm

      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)

    3. Scott Ryer
      Scott Ryer Staff June 23, 2020 at 2:21 pm

      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.

    4. tobi
      tobi June 23, 2020 at 2:59 pm

      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?

    5. Ryan Donovan
      Ryan Donovan June 23, 2020 at 3:57 pm

      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.

  16. Matt
    Matt May 15, 2020 at 11:15 am


    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!’ ) );

    1. Ryan Donovan
      Ryan Donovan May 15, 2020 at 12:42 pm

      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.

    2. Matt
      Matt May 15, 2020 at 12:56 pm

      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

  17. harvey
    harvey May 14, 2020 at 8:09 am

    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.

  18. Ed
    Ed May 8, 2020 at 8:54 am

    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.

  19. Nathan
    Nathan April 30, 2020 at 6:55 pm

    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?

  20. BV
    BV April 8, 2020 at 10:04 am

    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.

    Any insight would be helpful, thank you.

    1. Ryan Donovan
      Ryan Donovan April 8, 2020 at 11:17 am

      Hello BV, This is an interesting question. Could you please try and replace your configuration file with this one This file will focus in on the First and Last Name fields through the ‘fields’ array. 😀 That should do the trick for you.

    1. Cole
      Cole March 17, 2020 at 6:28 pm

      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?

    2. Ryan Donovan
      Ryan Donovan March 18, 2020 at 9:24 am

      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!

    3. Cole Schweikhardt
      Cole Schweikhardt March 18, 2020 at 10:58 am

      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 ( 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.

  21. Jordan Statham
    Jordan Statham March 5, 2020 at 6:40 am

    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.

    1. Ryan Donovan
      Ryan Donovan March 5, 2020 at 11:20 am

      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.😀

    2. Jordan Statham
      Jordan Statham March 5, 2020 at 11:27 am

      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.

    3. Ryan Donovan
      Ryan Donovan March 5, 2020 at 11:56 am

      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! 😁

  22. Chris McCoy
    Chris McCoy November 30, 2019 at 10:59 am

    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

    1. SeyntJim
      SeyntJim June 21, 2020 at 3:27 am


      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.

    2. David Smith
      David Smith Staff June 21, 2020 at 9:08 am

      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. 🙏

  23. Brian
    Brian November 5, 2019 at 11:30 am

    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.

  24. Ignatius Gouws
    Ignatius Gouws October 16, 2019 at 9:43 am

    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.

    1. David Smith
      David Smith Staff November 4, 2019 at 8:55 am

      Hi Ignatius, there is likely a rogue character in your PHP file. If you want to send your functions.php to me at, I’ll be happy to take a look. Please include a link to this message so your message is not auto-archived.

  25. Pete
    Pete October 11, 2019 at 11:10 pm

    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?


    1. Pete
      Pete October 14, 2019 at 9:56 am

      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

  26. ras
    ras September 28, 2019 at 5:03 pm

    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

    1. ras
      ras September 29, 2019 at 11:04 am

      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 .

  27. Swapnil
    Swapnil September 5, 2019 at 3:31 am

    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

    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

    thank You in advance

    1. David Smith
      David Smith Staff September 6, 2019 at 8:45 am

      You could certainly use this snippet as a basis for this functionality but it is not possible without further customization.

  28. Tyler
    Tyler May 7, 2019 at 12:01 pm

    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 –

    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

  29. Mostafa
    Mostafa April 16, 2019 at 3:52 pm

    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.

    1. Mostafa
      Mostafa April 18, 2019 at 8:37 am

      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

  30. Mijesch
    Mijesch March 20, 2019 at 3:48 am

    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.

  31. Tyler
    Tyler March 19, 2019 at 2:19 am

    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’ => ‘???’ ) );

    1. David Smith
      David Smith Staff March 20, 2019 at 9:14 am

      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 }

  32. Brandon
    Brandon March 13, 2019 at 1:22 pm

    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.

    1. David Smith
      David Smith Staff March 13, 2019 at 9:34 pm

      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.

  33. Jon
    Jon March 5, 2019 at 7:55 pm

    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?

  34. Frank
    Frank January 22, 2019 at 10:37 am

    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!!!

    1. David Smith
      David Smith Staff January 30, 2019 at 4:08 am

      Hi Frank, set the “apply_limit_per_form” as false to apply to all form IDs you’ve specified.

    1. David Smith
      David Smith Staff December 14, 2018 at 7:38 pm

      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.

    2. Dylan
      Dylan December 16, 2018 at 12:57 pm

      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.


    1. David Smith
      David Smith Staff November 10, 2018 at 6:36 am

      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. ?

  35. Gert-Jan Buth
    Gert-Jan Buth October 12, 2018 at 7:49 am

    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:

    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.

    1. David Smith
      David Smith Staff August 31, 2018 at 7:48 pm

      Hi Nicolas, the snippet version has not been updated to work with 2.3 yet. The plugin version does work with 2.3.

  36. Alex Shores
    Alex Shores August 2, 2018 at 11:49 am

    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.

    1. David Smith
      David Smith Staff August 2, 2018 at 2:21 pm

      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.

    2. Alex Shores
      Alex Shores August 2, 2018 at 2:24 pm

      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.

    3. Alex Shores
      Alex Shores August 3, 2018 at 4:57 pm

      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.

  37. Stephan Plesnik
    Stephan Plesnik July 19, 2018 at 6:35 am

    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?

    1. David Smith
      David Smith Staff July 24, 2018 at 5:48 pm

      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).

  38. Darin Densley
    Darin Densley July 5, 2018 at 2:44 pm

    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?

    1. David Smith
      David Smith Staff July 5, 2018 at 9:22 pm

      Hi Darin, sorry, GP Limit Submissions only works for limiting on successfully submitted entries.

    1. Joe
      Joe June 12, 2018 at 5:30 am

      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.

    2. David Smith
      David Smith Staff June 12, 2018 at 10:50 am

      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! ?

  39. Joe
    Joe June 11, 2018 at 4:24 pm

    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.

  40. John O'brien
    John O'brien April 17, 2018 at 12:25 pm

    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: 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!

    1. David Smith
      David Smith Staff April 18, 2018 at 9:54 am

      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. :)

  41. Olivier
    Olivier April 6, 2018 at 3:19 am

    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?



  42. Kenneth
    Kenneth March 6, 2018 at 8:16 am


    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

  43. Fardeen Chowdhury
    Fardeen Chowdhury February 22, 2018 at 12:24 pm



    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?

  44. Chris Geelhoed
    Chris Geelhoed January 16, 2018 at 5:23 pm

    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:

    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

    1. David Smith
      David Smith Staff January 20, 2018 at 7:27 pm

      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?

  45. Chaz
    Chaz January 15, 2018 at 5:02 pm

    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

  46. Santiago
    Santiago December 15, 2017 at 11:58 am

    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!

    1. Santiago
      Santiago December 15, 2017 at 12:05 pm

      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

  47. Alain TERRIEUR
    Alain TERRIEUR October 25, 2017 at 11:41 am

    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

  48. Matthew
    Matthew October 18, 2017 at 6:45 am


    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?

    1. David Smith
      David Smith Staff October 25, 2017 at 12:16 pm

      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.

  49. Leo Dunkelberger
    Leo Dunkelberger October 16, 2017 at 5:49 pm

    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!

    1. David Smith
      David Smith Staff October 25, 2017 at 12:19 pm

      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( ... ) }

  50. Frank
    Frank October 16, 2017 at 2:26 pm

    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

    1. David Smith
      David Smith Staff October 25, 2017 at 12:23 pm

      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.

  51. Smith
    Smith October 9, 2017 at 1:52 pm

    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.

  52. Mass
    Mass October 3, 2017 at 2:15 pm

    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?

    1. David Smith
      David Smith Staff October 15, 2017 at 5:17 pm

      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.

  53. John
    John September 27, 2017 at 4:52 am

    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.

    1. David Smith
      David Smith Staff September 30, 2017 at 1:54 pm

      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?

  54. Rae
    Rae September 18, 2017 at 6:09 pm

    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.

    1. David Smith
      David Smith Staff September 18, 2017 at 9:57 pm

      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?

    2. Rae Heitkamp
      Rae Heitkamp September 19, 2017 at 11:22 am

      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. :)

  55. Rob Davis
    Rob Davis September 6, 2017 at 2:10 pm

    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

    1. David Smith
      David Smith Staff September 6, 2017 at 2:41 pm

      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. :)

    2. Rob Davis
      Rob Davis September 6, 2017 at 4:42 pm

      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.

    3. Rob Davis
      Rob Davis September 6, 2017 at 5:13 pm

      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

    4. David Smith
      David Smith Staff September 7, 2017 at 8:54 am

      Hi Rob, I would expect that configuration to work. This will be a non-issue once you’re running GP LImit Submissions.

  56. Damian Smith
    Damian Smith August 21, 2017 at 10:27 am


    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?

    1. Damian Smith
      Damian Smith August 22, 2017 at 5:06 am

      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?

    2. Damian Smith
      Damian Smith August 22, 2017 at 9:23 am

      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 :(

    3. David Smith
      David Smith Staff August 22, 2017 at 4:48 pm

      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.

  57. Zeyad
    Zeyad August 14, 2017 at 7:27 pm

    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.


    1. Zeyad
      Zeyad August 15, 2017 at 5:38 pm

      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?

    2. David Smith
      David Smith Staff August 16, 2017 at 6:59 am

      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).

  58. Kerry
    Kerry August 11, 2017 at 9:20 pm

    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!!!

    1. David Smith
      David Smith Staff August 12, 2017 at 6:14 pm

      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.

    2. Kerry
      Kerry August 13, 2017 at 9:06 pm

      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:

    3. Kerry
      Kerry August 15, 2017 at 1:44 pm

      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:

      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

      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!!

    4. David Smith
      David Smith Staff August 15, 2017 at 4:50 pm

      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?

    5. Kerry
      Kerry August 16, 2017 at 9:40 pm

      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!

    6. David Smith
      David Smith Staff August 17, 2017 at 6:58 am

      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.

  59. Primoz
    Primoz July 26, 2017 at 9:05 am

    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?

    1. David Smith
      David Smith Staff July 30, 2017 at 9:55 am

      This does limit after the user has submitted the form. You’re only seeing the limit message because you’ve already exceeded the limit.

  60. Mark
    Mark July 25, 2017 at 9:22 pm

    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,


  61. Miles
    Miles July 18, 2017 at 6:41 pm

    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!

    1. Miles
      Miles July 19, 2017 at 12:13 pm

      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

    2. Miles
      Miles July 20, 2017 at 9:52 am

      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.

    3. David Smith
      David Smith Staff July 20, 2017 at 10:16 am

      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.

    4. Miles
      Miles July 20, 2017 at 5:59 pm

      WARNING, this snippet for some reason causes some issues in the WordPress back end. Using this plugin: 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.

  62. Miles
    Miles July 17, 2017 at 12:13 pm

    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.

  63. jack
    jack July 17, 2017 at 1:45 am

    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.

    1. jack
      jack July 19, 2017 at 3:42 pm

      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.

    2. David Smith
      David Smith Staff July 19, 2017 at 8:06 pm

      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.

  64. Ryan
    Ryan July 15, 2017 at 12:43 pm


    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.

    1. Omar
      Omar July 13, 2017 at 11:32 am

      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/

    2. David Smith
      David Smith Staff July 13, 2017 at 11:47 am

      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.

  65. Joni Kukkohovi
    Joni Kukkohovi July 12, 2017 at 4:06 am


    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!

    1. Joni Kukkohovi
      Joni Kukkohovi July 14, 2017 at 4:39 pm

      Thanks David. Question, is this function available through Gravity Perks or just a snippet?

    2. David Smith
      David Smith Staff July 14, 2017 at 8:16 pm

      Currently, just this snippet. We are getting very close to releasing the perk version. :)

  66. Justine
    Justine July 11, 2017 at 10:45 pm

    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?

    1. Justine
      Justine July 19, 2017 at 3:23 pm

      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?

    2. David Smith
      David Smith Staff July 20, 2017 at 10:20 am

      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.

    3. Justine
      Justine July 20, 2017 at 5:45 pm

      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.

    4. Miles
      Miles July 20, 2017 at 5:53 pm

      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: 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.

    5. Justine
      Justine July 20, 2017 at 9:07 pm

      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.

  67. Rachel
    Rachel July 6, 2017 at 9:47 am

    (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.

    1. David Smith
      David Smith Staff July 14, 2017 at 12:48 pm

      Hi Rachel, the plugin version is about 85% done! There is no simple way to compress the code.

  68. Dan
    Dan July 1, 2017 at 3:47 pm

    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.

    1. David Smith
      David Smith Staff July 2, 2017 at 8:05 am

      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.

    2. Dan
      Dan July 6, 2017 at 2:51 pm

      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?

  69. Michael McPeek
    Michael McPeek June 27, 2017 at 1:43 pm

    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.

    1. Michael
      Michael June 28, 2017 at 9:37 am

      Haha, yeah, naturally I tried that just AFTER posting. Thanks again for the great snippet and for your help!

  70. Santiago Cabrera
    Santiago Cabrera June 27, 2017 at 1:05 pm

    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.


    1. David Smith
      David Smith Staff June 28, 2017 at 11:49 am

      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?

    2. Santiago Cabrera
      Santiago Cabrera June 29, 2017 at 3:56 am

      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!

    3. Santiago Cabrera
      Santiago Cabrera June 29, 2017 at 8:21 am

      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

    4. David Smith
      David Smith Staff June 29, 2017 at 10:38 am

      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.

      new GW_Submission_Limit( array(
          'form_id' => 1,
          'limit_by' => 'field_value',
          'limit' => array(
              // "2" is your field ID, "1" is your limit for this field ID
              2 => 1 
          'time_period' => 'per_day'
      ) );

  71. Anthony Giuliano
    Anthony Giuliano June 8, 2017 at 4:39 pm

    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?

    1. David Smith
      David Smith Staff June 8, 2017 at 5:29 pm

      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.

    2. Anthony Giuliano
      Anthony Giuliano June 8, 2017 at 6:01 pm

      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

    3. David Smith
      David Smith Staff June 8, 2017 at 7:51 pm

      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.

    4. Anthony Giuliano
      Anthony Giuliano June 8, 2017 at 9:13 pm

      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 :)

    5. Anthony Giuliano
      Anthony Giuliano June 8, 2017 at 11:08 pm

      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.

  72. Johan Dahl
    Johan Dahl June 8, 2017 at 5:05 am


    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? :)

    1. David Smith
      David Smith Staff June 8, 2017 at 8:34 am

      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.

    1. Anthony Giuliano
      Anthony Giuliano June 6, 2017 at 9:20 pm

      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 { }

    2. David Smith
      David Smith Staff June 6, 2017 at 9:48 pm

      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.

  73. Ivan
    Ivan May 31, 2017 at 8:56 pm

    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?

    1. David Smith
      David Smith Staff May 31, 2017 at 10:21 pm

      Hi Ivan, this snippet does not currently support that. I’ve added it to the feature requests. :)

  74. Michael
    Michael May 25, 2017 at 4:16 pm

    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?


    1. David Smith
      David Smith Staff May 28, 2017 at 12:00 pm

      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.

  75. corporatic
    corporatic May 12, 2017 at 3:50 pm


    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

  76. Dan
    Dan May 8, 2017 at 7:58 am

    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.


    1. David Smith
      David Smith Staff May 8, 2017 at 10:33 am

      Hi Dan, it looks like you’ve specified the “limit” parameter twice. Try removing this line:

      'limit' => 1,

    2. Dan
      Dan May 8, 2017 at 2:13 pm

      Hi there

      I tried that but it didn’t make a difference. Are you sure this should work:

      thanks, see attached code:

    3. David Smith
      David Smith Staff May 9, 2017 at 8:22 am

      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.

    4. David
      David May 11, 2017 at 1:01 pm

      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

    5. David Smith
      David Smith Staff May 11, 2017 at 9:10 pm

      Hey David, if you don’t want a role limited, excluding it from the list or role limits all-together should do the trick.

  77. Kenny
    Kenny April 28, 2017 at 10:38 am

    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.

  78. luca Recchia
    luca Recchia April 27, 2017 at 7:42 am

    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

  79. Ruben
    Ruben April 20, 2017 at 7:46 pm

    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?

  80. AG
    AG April 11, 2017 at 8:40 pm

    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?

  81. Asaf Epshtain
    Asaf Epshtain March 12, 2017 at 2:53 pm


    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.


  82. corporatic
    corporatic March 9, 2017 at 4:24 am


    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

  83. Reinald
    Reinald March 7, 2017 at 12:25 pm

    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!

    1. David Smith
      David Smith Staff March 7, 2017 at 9:25 pm

      Hi Reinald, you would need to update the snippet to call do_shortcodes() anywhere the limit_message parameter is referenced. :)

    2. Reinald
      Reinald March 10, 2017 at 10:35 am


      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:

    3. David Smith
      David Smith Staff March 12, 2017 at 9:23 pm

      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.

  84. Andrei G.
    Andrei G. March 3, 2017 at 12:27 pm

    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.


    1. David Smith
      David Smith Staff March 4, 2017 at 6:49 pm

      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,

    2. Andrei G.
      Andrei G. March 9, 2017 at 12:45 pm


      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?


  85. corporatic
    corporatic February 28, 2017 at 7:14 am

    Hi, one more issue…

    I´m using Stickylist to update forms but if limit is reached I can´t edit.

    Any ideas?

    Thanks again

    1. David Smith
      David Smith Staff February 28, 2017 at 8:07 am

      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.

  86. corporatic
    corporatic February 27, 2017 at 12:16 pm

    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.


    1. David Smith
      David Smith Staff February 27, 2017 at 5:24 pm

      You can provide an array of roles to limit by:

      ‘limit’ => array( ‘administrator’ => 0, ‘editor’ => 0, ‘author’ => 1 )

    2. Corporatic
      Corporatic February 27, 2017 at 6:59 pm

      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

  87. Tal
    Tal February 14, 2017 at 10:51 pm

    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:

    Thanks a lot!

    1. Tal
      Tal February 15, 2017 at 8:13 am

      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.

    2. David Smith
      David Smith Staff February 15, 2017 at 8:29 am

      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.

  88. John Doherty
    John Doherty February 14, 2017 at 10:31 am

    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?

    1. John Doherty
      John Doherty February 14, 2017 at 12:45 pm

      Thanks David. I’m getting a “Call to undefined method GW_Submission_Limit” error. I pasted my code.

    2. David Smith
      David Smith Staff February 14, 2017 at 2:03 pm

      Hm, not sure, John. If that is the full file, I can’t see any reason why that error would be generated.

    3. John Doherty
      John Doherty February 14, 2017 at 2:25 pm

      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?

    4. John Doherty
      John Doherty February 14, 2017 at 2:44 pm

      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.

    5. John Doherty
      John Doherty February 14, 2017 at 5:48 pm

      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?

  89. Paul
    Paul February 1, 2017 at 5:24 am

    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 :-/

    1. David Smith
      David Smith Staff February 1, 2017 at 8:58 am

      Hi Paul, if you don’t have hundreds of forms, here’s an approach you can use to do this.

    2. Paul
      Paul February 1, 2017 at 2:05 pm

      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

  90. K A
    K A January 26, 2017 at 3:41 am

    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?


  91. javier
    javier January 19, 2017 at 2:32 am

    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

    1. David Smith
      David Smith Staff January 19, 2017 at 7:15 am

      Here’s how I would approach this.

      1. Install and activate GP Unique ID.
      2. Copy and paste this snippet into your theme’s functions.php file.
      3. Add a new Single Line Text field to your form.
      4. Enable the “No Duplicates” option.
      5. Add “uid” as the Dynamic Population parameter on the Advanced tab.
      6. Set the Visibility to “Hidden”.

      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.

    2. javier
      javier January 24, 2017 at 11:40 am

      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.

    3. Copy and paste this snippet into your theme’s functions.php file.
    4. 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

  92. Natalie Osborne
    Natalie Osborne January 17, 2017 at 3:04 pm

    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?

  93. John
    John January 10, 2017 at 9:33 am

    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?

    1. David Smith
      David Smith Staff January 10, 2017 at 5:25 pm

      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.

    2. John
      John January 10, 2017 at 7:54 pm

      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.

    3. David Smith
      David Smith Staff January 10, 2017 at 9:04 pm

      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?

    4. John
      John January 10, 2017 at 10:31 pm

      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.

    5. John
      John January 11, 2017 at 11:17 am

      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.

    6. David Smith
      David Smith Staff January 11, 2017 at 11:22 am

      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 )’;

    7. John
      John January 13, 2017 at 2:56 pm

      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?

  94. Tahar
    Tahar January 9, 2017 at 2:31 pm

    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.


    1. Tahar
      Tahar January 10, 2017 at 9:37 am

      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!

    2. David Smith
      David Smith Staff January 10, 2017 at 5:26 pm

      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.

    1. David Smith
      David Smith Staff December 24, 2016 at 1:31 pm

      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).

    2. John
      John December 24, 2016 at 10:57 pm

      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.

    3. David Smith
      David Smith Staff December 25, 2016 at 7:08 am

      I would expect you configuration to work… but give this alternate configuration a try anyways (see related code).

    4. John
      John December 25, 2016 at 9:15 am

      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!

  95. Razvan
    Razvan December 19, 2016 at 11:41 pm

    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

    1. David Smith
      David Smith Staff December 20, 2016 at 7:40 am

      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.

    2. Razvan
      Razvan December 21, 2016 at 12:49 am

      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

    3. Razvan
      Razvan December 21, 2016 at 2:21 am

      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

  96. Thorsten
    Thorsten December 6, 2016 at 7:49 am

    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 ?

  97. Doug
    Doug October 28, 2016 at 8:58 am

    Hi David,

    Thanks so much for this code! It works beautifully! I was also wondering, like Roberto ( 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”.

    1. Doug
      Doug October 31, 2016 at 9:23 am

      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!

  98. Bradley
    Bradley October 25, 2016 at 11:20 am

    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?


  99. Jason Narciso
    Jason Narciso October 24, 2016 at 8:37 am

    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.

  100. Chris
    Chris October 18, 2016 at 5:10 am

    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.

  101. Rob Davis
    Rob Davis October 11, 2016 at 4:51 pm

    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!

    1. David Smith
      David Smith Staff October 13, 2016 at 3:16 pm

      Hi Rob, looks like you’re missing a comma before the ‘limit_by’ parameter:

      ‘form_id’ => array(1,18,19,20,21), ‘limit_by’

  102. Phil K
    Phil K October 9, 2016 at 9:38 pm

    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?

    1. Phil K
      Phil K October 14, 2016 at 6:22 pm

      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.

    2. David Smith
      David Smith Staff October 14, 2016 at 9:30 pm

      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.

  103. Roberto
    Roberto October 5, 2016 at 2:27 am

    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?

    1. David Smith
      David Smith Staff October 6, 2016 at 9:54 pm
      1. I sent you some code via Gravity Perks support.
      2. You can search for all entries created by a user on the entry list page and then trash them.
    1. David Smith
      David Smith Staff October 5, 2016 at 11:58 am

      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.

  104. Wes
    Wes September 11, 2016 at 12:19 am

    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’ => ‘



    ‘ ) );

    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

    1. David Smith
      David Smith Staff September 24, 2016 at 12:48 am

      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.

  105. Emilien
    Emilien August 16, 2016 at 4:14 am

    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,


    1. Emilien
      Emilien August 16, 2016 at 6:07 am

      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!

  106. Daniel Gutierrez
    Daniel Gutierrez August 2, 2016 at 7:04 pm

    Hello David! This looks very promising for my need:

    We have developed 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!

    1. Daniel Gutierrez
      Daniel Gutierrez August 2, 2016 at 7:34 pm

      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, ) );

    2. David Smith
      David Smith Staff August 8, 2016 at 2:58 pm

      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:

      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.

    3. Daniel Gutiérrez
      Daniel Gutiérrez August 21, 2016 at 1:06 pm

      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!

  107. Matthew
    Matthew July 18, 2016 at 7:00 pm

    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!


    1. David Smith
      David Smith Staff August 8, 2016 at 12:36 pm

      Hi Matt, are the duplicates caused by the user deliberately submitting the same information twice?

    2. Matthew
      Matthew August 8, 2016 at 3:51 pm

      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,


  108. Jd
    Jd July 5, 2016 at 11:22 am

    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

  109. Chris
    Chris July 4, 2016 at 10:13 pm

    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 ) {

        if( ! $this->is_applicable_form( $form ) || ! $this->is_limit_reached( $form['id'] ) ) {
            return $form;

    ( GFFormDisplay::$submission, $form[‘id’] );

        $submission_info = rgar
        // if no submission, hide form
        // if submission and not valid, hide form
        // unless 'field_value' limiter is applied
        if( ( ! $submission_info || ! rgar( $submission_info, 'is_valid' ) ) && ! $this->is_limited_by_field_value() ) {
            add_filter( 'gform_get_form_filter_' . $form['id'], create_function( '', 'return \'<div class="limit-message">' . $this->_args['limit_message'] . '</div>\';' ) );
        return $form;
    1. David Smith
      David Smith Staff July 15, 2016 at 9:04 am

      Hi Chris, are you just looking for shortcode support for the “limit_message” property?

  110. Robert de Leeuw
    Robert de Leeuw June 23, 2016 at 10:43 am

    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

    1. David Smith
      David Smith Staff June 30, 2016 at 8:53 am

      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 ) );

    1. David Smith
      David Smith Staff June 30, 2016 at 8:53 am

      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.

  111. ML
    ML June 4, 2016 at 3:54 pm

    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?

    1. ML
      ML June 6, 2016 at 2:43 pm

      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

  112. vlo
    vlo May 31, 2016 at 8:24 am

    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?

  113. vlo
    vlo May 31, 2016 at 7:40 am

    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?

  114. nathan
    nathan May 29, 2016 at 11:10 pm

    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…

  115. Joe
    Joe May 18, 2016 at 7:58 am

    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.

    1. Joe
      Joe May 18, 2016 at 9:35 am

      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.

    2. Joe Mallion
      Joe Mallion May 23, 2016 at 9:25 am

      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?

    3. David Smith
      David Smith Staff May 24, 2016 at 8:57 am

      Hi Joe, yup, that’s right. Add a Hidden field to act as your quantity field.

    4. Joe Mallion
      Joe Mallion May 24, 2016 at 9:42 am

      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? :)

  116. Christopher
    Christopher May 12, 2016 at 6:57 am


    On a multisite installation how can exclude super admin from “Limit by Role” limitations?


  117. Emilien
    Emilien May 12, 2016 at 4:25 am

    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

    1. David Smith
      David Smith Staff May 18, 2016 at 10:01 am

      It is not currently possible to set the time period between to dates. Could you elaborate on #2? What do you mean by $variables?

  118. Emilien
    Emilien May 11, 2016 at 8:04 am

    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:


    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’ ) );

    • those two functions return two variable : $nb and $length. I can’t get the snippet to work if I set things like this either:


    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’ ) );

    • Using WP Debug I either get “undefined function error” or “undefined variable error”… I guess this is a syntax problem but I’m not sure how to solve this.

    Thank you so much in advance for your help, have a great day, Emilien

    1. David Smith
      David Smith Staff May 24, 2016 at 9:22 am

      I would actually expect that to work… Are your functions defined above the snippet?

  119. Bob
    Bob May 10, 2016 at 5:03 am

    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,


    1. David Smith
      David Smith Staff May 18, 2016 at 12:21 pm

      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.

  120. Steve
    Steve May 4, 2016 at 5:13 pm

    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

    1. David Smith
      David Smith Staff May 24, 2016 at 9:06 am

      Hi Steve, the snippet has been updated support limiting per week. Using “week” or “per_week” as the time period.

  121. David
    David April 29, 2016 at 6:08 pm

    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

    1. David Smith
      David Smith Staff April 29, 2016 at 10:04 pm

      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.

  122. Alex
    Alex April 22, 2016 at 10:08 am

    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.

  123. David
    David April 20, 2016 at 7:29 pm

    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‘ ) );

    Any suggestions? This site is supposed to go live in two days :/

  124. Armando
    Armando March 29, 2016 at 7:26 pm

    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!

    1. Armando
      Armando March 29, 2016 at 9:33 pm

      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!

    2. Armando
      Armando March 30, 2016 at 3:27 pm

      Hey Dan, thanks again for your time. I really appreciate it. I understand now, thats what I was looking for was that limit function. I have two more questions:

      The code you provided kills my page on the if statement. I did the following:

      1- I put your code in my functions file as is. Page won’t load. 2- I put the IF statement in a function so I can recall it on my template page. Same result. 3- I put all code in my template page. Same result.

      I would like to mention that I put your initial snippet in a plugin I created for it so it can live outside the functions file.

      Again, I appreciate your help!

  125. mkp
    mkp March 23, 2016 at 3:45 am


    thank you for this great snippet. I’d like to ask, how to display the form when user submit.

    I used your snippet with poll addons, i still need user can see the poll result after they are do submission.

    currently after user submit the form, they cannot see the result. but this snippet really block multiple submission

    thank you

  126. Jacob Haas
    Jacob Haas March 16, 2016 at 12:51 am

    Hi, I am having a minor issue right now, I need to be able to limit entries by user name, this feature is working great, however I would like to be able to allow unlimited entries by the administrators of the site for demo purposes, is this possible?

    Here is the basic code I think I need.

    new GW_Submission_Limit( array( ‘form_id’ => 25, ‘limit’ => array(1,’broker’=>1, ’employer’=>1, ‘subscriber’=>1, ’employee’=>1), ‘limit_by’=>array(‘user_id’,’role’), ‘limit_message’ => ‘You have already filled out this form’ ) );

    Thank You for your help, I’m loving the code so far.

    1. David Smith
      David Smith Staff March 25, 2016 at 4:28 pm

      Hi Jacob, just add a limit for the ‘administrator’ role and set it to 99999. That is essentially unlimited. Also, you only need the ‘role’ for your limit_by parameter since it automatically applies to the individual user and not the role as a group.

  127. Joel Newcomer
    Joel Newcomer March 15, 2016 at 4:49 pm

    Any idea how to make this work with a value in a list field and make sure all values are unique in a particular column? We are trying to prevent a user from entering the same invoice number twice in the first column in a list field. The form is here and the field I’m working with is field 14, column 1 (“Invoice # or Reason for payment”). Any help would be greatly appreciated! Thank you for making this awesome tool available to the community.

  128. Fabien HERISSON
    Fabien HERISSON March 7, 2016 at 4:41 am


    I try to limit to one submission to a form (ID 14) for users. Actually, form is only visible for registered users and i set the display of this form until 2016-03-31. I add the code to my functions.php but don’t know what to set in portion of snippet. Thanks for your help.

    1. David Smith
      David Smith Staff March 8, 2016 at 12:08 pm

      Hi Fabien, you’ll just need to specify the “form_id” parameter and the “limit” parameter. See the “Basic Usage” section above for an example.

  129. Lucas
    Lucas February 15, 2016 at 3:38 pm

    Hi there, this snippet is really helpful but it does no fill 100% my needings. I’m using gravityforms with survey addon to use one survey for every post i have. As I said your snippet does the hard work of limiting the number of times a user fills a survey in different url’s but when I have a look on the results… well, all data is treated globally. Do you have snippet or idea to make the results display by post and not globally for a given survey. Thanks in advance.

    1. Lucas
      Lucas February 18, 2016 at 11:34 pm

      No problem, I found a way for doing it with conditional results applying it to a hidden url field, thanks anyway!

  130. Paul DiCecco
    Paul DiCecco February 15, 2016 at 3:31 pm


    I’ve added the full php file to my functions file minus the starting <?php tag

    I have edited the config at the bottom as follows

    new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘field_value’, ‘limit’ => array( // “2” is your field ID, “6” is your limit for this field ID 4 => 1 ), ‘time_period’ => 60, // forever! ‘limit_message’ => __( ‘Sorry, you have reached the submission limit for this form.’ ), ‘apply_limit_per_form’ => true, ‘enable_notifications’ => false ) );

    I want to limit to 1 submission per email per day. I thought by setting it to 60 would allow me to test it if I submitted a second entry after a couple of minutes but it continues to deny me and there is no limit message appearing. Is there something I am doing wrong here?

    Thanks, Paul

    1. Paul DiCecco
      Paul DiCecco February 15, 2016 at 3:36 pm

      nevermind.. I had no duplicates enabled.. once I disabled that it is working fine now.. I even see the limit message below the fields.. thanks..

  131. James Bronson
    James Bronson January 20, 2016 at 7:31 pm

    Great snippet btw! I am trying to modify it slightly so that instead of using a field id it uses a field type.

    As an example, I have a custom GravityForms field call my_dob that I use. When validating I usually loop through the fields in the form until I find it but for some reason I can’t access the $form variable inside this snippet.

    Can you help?

  132. Roman Shrestha
    Roman Shrestha January 20, 2016 at 4:14 am

    Hi, I have used this it is great but I have one query. If I have 10 forms, can I limit the form submission for 9 forms and not limit for 1 form?

    Recently form_id only takes the value of form which has to be limited. Do you have certain parameter to which we pass the value of the form whose value we don’t want to limit.???

  133. Daniel Maier
    Daniel Maier January 13, 2016 at 10:58 am

    Hello, first thanks for the excellent snippet!

    Is there a way to block the user by IP address and a field_value but display the IP restriction message first and if the user tries using a different IP as soon as the user uses the same field_value (i.e., email address) the user will see the limit message due to the email address already being used?


    new GW_Submission_Limit(array( 'form_id' => 13, 'limit' => 2, 'limit_by' => array( 'field_value', 'ip' ), 'fields' => array( '5' ), 'time_period' => 'per_month', 'limit_message' => '


    ', ));


  134. Kelsey
    Kelsey December 29, 2015 at 5:28 pm

    My form can be found here:

    Currently I have am using this as my configuration:

    new GW_Submission_Limit( array( ‘form_id’ => 2, ‘limit’ => 1, ‘limit_by’ => ip, ‘time_period’ => false, ‘limit_message’ => ‘We love that you love our products, but unfortunately you can only submit this form once!’

    A few questions:

    Does it block the IP at the last form page on the Paypal form? Can I add a way to block the physical address form that I have in there too?

    Thank you!

    1. David Smith
      David Smith Staff December 30, 2015 at 7:11 am

      Hi Kelsey, typically the same IP is used by a user for every page they access on your website (and their entire browsing session). I wasn’t clear on what you meant when you asked if you can block the physical address but I think you might be referring to the “embed_url” parameter. More details above.

    2. Kelsey
      Kelsey December 30, 2015 at 8:54 am

      Hey David,

      Sorry, maybe I didn’t explain very well.

      My first question in reference to my specific form was should have been: With the parameters I had used for this code I had blocked the duplicate submissions via the IP address. At what point of my form is it where that is actually applied. Is it the last page of the form? Or the beginning? I was just curious with how I have my form set up where that would actually take place.

      My next question was pertaining to the address fields that I have in the second page of my form. I was asking if there was a way that I can ALSO block duplicate submissions via that paramater as well as the IP address.

      A little bit of background on the form – we are offering free samples and we don’t want to end up sending out a million free samples to the same person.

      Looking forward to hearing from you. And thank you!

    3. David Smith
      David Smith Staff December 30, 2015 at 4:32 pm

      Hi Kelsey, if the limit is 1, the user would be able to submit the form once. If they attempt to load the form again, the limit message would be displayed. You can limit by multiple identifiers (i.e. “ip” and “field_value”). This example is for a Name field. You could convert it to work for an address field as well by changing the “2.3” and “2.6” to the input IDs for each input of the Address field.

      new GW_Submission_Limit( array(
           'form_id'     => 327,
           'limit_by'    => array( 'field_value', 'ip' ),
           'fields'      => array( '2.3', '2.6' ),
           'limit'       => 1,
           'time_period' => false
       ) );

  135. Rob
    Rob December 28, 2015 at 11:09 pm

    David, you are an absolute legend!

    I had an issue with duplicate entries and have been trying to find the culprit for days. I couldn’t find any plugin/theme conflicts and after using the Gravity Forms logging plugin, the Gravity Forms support team seem the think users have been inadvertently refreshing the page, hence causing the dup.

    Thank you so much for providing this snippet, it works very well and is pretty flexible :)

  136. Xavier
    Xavier December 15, 2015 at 6:11 am

    Hi David,

    I was wondering if there was a way to limit submision until a fixed date (i.e. until December 31st 2015), not only by a relative calendar time period (i.e. ‘per day’, ‘per month’).

    Great work, and thanks!


    1. David Smith
      David Smith Staff December 15, 2015 at 7:04 am

      Hi Xavier, add this function below the snippet and then call it for the “time_period” parameter, like so:

      'time_period' => gw_day_diff( '2015-12-31' )

      It’s not a perfect solution. After the date is exceeded, the limit will be applied with no time period.

  137. Ben
    Ben November 11, 2015 at 12:15 pm


    I installed this code and it works perfectly, but was wondering if there was a way to have the form still visible for viewing but locked for submitting.

    In our form the user selects a few choices, but sometimes wants to add or change the choices, but cant see them anymore once it is submitted.

    Great code, and thanks again!

  138. CC
    CC November 6, 2015 at 6:10 am

    This is simply fantastic!

    It’s not the first time I stumble upon a great Gravity Form tutorial on this website. I’ve been using the Conditional Logic with Dates method ( ) for ages to apply limited-time discounts on my forms.

    Actually, is there a way to combine these two methods? What I mean is: Say, for example, I want the sum total of purchases on a particular product that I seel through my form to be 20, but since my form is set up with a discount in a certain date range, instead of having a single field {price} I actually have two fields, {price_discount} and {price_regular}, that become available on an aut-aut basis (either the former or the latter) based on the submission date, as per the Conditional Logic with Dates tutorial.

    So I’d like to have 20 total entries on {price_discount} + {price_regular}, but I don’t care how they are distrubuted (I may have 10 {price_discount} + 10 {price_regular} = 20, or I may have 2 {price_discount} + 18 {price_regular} = 20 etc. etc.).

    Is there a way to do this?

  139. Andrea
    Andrea November 4, 2015 at 4:26 am

    hello, I do not know where to put the code in function.php, whether above or below, anywhere I go inside you I see a white screen (I think it is error of <? php and closing, so I wordpress problems .. .) Help!

  140. Zeshan Ahmed
    Zeshan Ahmed November 2, 2015 at 9:37 am

    Works perfectly. This is exactly what I was looking for. It’s a pity Gravity form doesn’t provide this functionality by default.

    Thanks again!

  141. Andrei G.
    Andrei G. October 29, 2015 at 9:43 am


    Thank you for this great code. All works great except the message configured to show if limit reached does not show the translation available for it.

    I used it as follows:

    new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit’ => 1, ‘time_period’ => ‘per_month’, ‘limit_by’ => ‘user_id’, ‘limit_message’ => __(‘You have already submitted this month.’, “beautclick”)

    I am using WPML and string translation. The string registers fine and I added a translation for it, but when viewing the page the English message still appears.

    Any ideas?


    1. David Smith
      David Smith Staff October 29, 2015 at 10:19 am

      Hi Andrei, I believe WPML has a way to register strings for translation and then a separate method for retrieving the correct string based on the selected language. This is something they’ll be better equipped to advice on. I’d love to hear their answer.

    2. Andrei G.
      Andrei G. October 29, 2015 at 10:25 am

      Hi David,

      Indeed, you can register strings with the gettext function __(“String to be translated”, “theme-domain), as you already had in the code (line 32).

      That allows for the string to be registered and a translation added.

      I was able to get it working finally by modifying your code on line 76. I replaced ($this->_args[‘limit_message’] with:


      So I basically just wrapped all that in the gettext function. I had found the solution here:

      Now, I didn’t check all your code to see if there is any other place where this needs to be done, but it works for my purpose.

      If you could go over it all and update it as needed, I think it may help a lot of people.

      Thanks again.

    3. David Smith
      David Smith Staff October 29, 2015 at 10:34 am

      Hm, that seems odd. So this works:


      …but this doesn’t?

      new GW_Submission_Limit( 
          array( ‘limit_message’ => __(‘You have already submitted this month.’, “theme-domain” ) )

    4. Andrei G.
      Andrei G. October 29, 2015 at 12:43 pm

      Both must be present for everything to work.

      So, the following line allows you to register a string for translation (and enter a translation via WPML’s String Translation interface) :

      array( ‘limit_message’ => __(‘You have already submitted this month.’, “theme-domain” ) )

      And this line basically allows for that translation to be fetched (otherwise it will simply return the English version):


    5. Andrei G.
      Andrei G. October 29, 2015 at 12:48 pm

      As a side note, if you were to simply output the string directly, it would just work, but the additional wrap in the gettext function is needed because you’re calling a variable and that’s when the output actually happens.

      So this would work fine, in the sense that it would automatically fetch the associated translation, if any:

      __(‘You have already submitted this month.’, “theme-domain” )

    6. Andrei G.
      Andrei G. October 29, 2015 at 12:50 pm

      Sorry, the last line of code in my previous comment should be:

      echo "__(‘You have already submitted this month.’, “theme-domain” )";

      (not sure how to edit the comment).

    7. David Smith
      David Smith Staff October 30, 2015 at 7:53 am

      Hi Andrei, thanks for all your feedback.

      This method of calling the __() function twice on the same string seems a little funky. WPML doesn’t know when the string is actually being output to the screen because __() always returns the string and never outputs it. The echo that precedes it is what actually outputs it to the screen and WPML (which is using the “gettext” filter) would have no knowledge of the context from which __() is being called.

      My gut is that this is an order of events issue. Try initializing the snippet later in the page load process, like so:

      add_action( 'wp', function() {
          new GW_Submission_Limit( 
              array( ‘limit_message’ => __(‘You have already submitted this month.’, “theme-domain” ) )
      } );

    8. Andrei G.
      Andrei G. October 30, 2015 at 1:46 pm


      I tried using the add_action as you suggested, but that seems to break the limiting. In other words, the form is no longer limited and gets display as normal.

      I know it’s a little funky and indeed, gettext doesn’t know about the echo.. but I believe it’s more about context. At the time the variable (limit_message) gets initialized, WPML has no knowledge of what language you’re browsing in, so it doesn’t know it needs to set/load the limit_message in French and then pass it in French down the road.

      Whereas when it comes time to echo, the wpml language variable is respected, so it knows you’re trying to display something in a certain language. Then it’s a matter of finding what the original text/string is and display the equivalent translation.

      Not sure if I manage to explain clearly here. Let me know if it makes any sense.

    9. David Smith
      David Smith Staff October 31, 2015 at 9:31 am

      I was able to recreate the issue where delaying the initialization failed to limit the form. Try initializing the snippet like this:

      I think what is happening is that the string is being parsed by __() before WPML has a chance to do anything with it. By delaying the init (and therefore when the limit message variable is parsed by __(), I think it will give WPML a chance to intercept it.

  142. Giacomo
    Giacomo October 16, 2015 at 8:48 am

    Hi David, i can use this code for all my form and add some exception? i need this feature for 99 of 100 forms , but the last form? how i can unset this limitation?

  143. Gravityforms Poll - how to limit by email address October 6, 2015 at 2:49 pm

    […] else out there has done this before. I did a little search online and found this really handy PHP snippet from GravityWiz which gives you the ability to limit by IP as well as many other parameters (quoted from their […]

  144. Vitaly
    Vitaly October 2, 2015 at 9:26 am

    One question, is it possible with this snippet to achieve this: one submission per user per url and same time 10 submissions in total per url?

  145. Vitaly
    Vitaly October 2, 2015 at 6:12 am

    Multiple Limiters line: ‘limit_by’ => array( ’embed_url’, ‘user_id’ ) makes wp white page and debugging shows: Parse error: syntax error, unexpected ”limit_by” (T_CONSTANT_ENCAPSED_STRING), expecting ‘)’

    Just deleting the line and everything else works

    1. David Smith
      David Smith Staff October 2, 2015 at 7:04 am

      Try adding a comma at the end of the line:

      'limit_by' => array( 'embed_url', 'user_id' ),

  146. PATRICK
    PATRICK September 28, 2015 at 8:43 pm

    Hey David, great stuff! I had a quick question…

    I’m using Gravity forms to handle registration for this free event. There is a drop down in the form, and I need each option in that drop down to have a different limit on it before it becomes disabled. For example:

    Option 1 disables after 100 submissions Option 2 disables after 50 submissions Option 3 disables after 100 submissions

    etc etc.

    Is that possible with any of these snippets? I thought ‘Limit by Field Value’ might do it but looks like that only limits how many times a field can be used.

    Thanks Patrick

  147. Miguel
    Miguel September 22, 2015 at 12:05 pm


    I need to exclude some form ids to use this limit.

    So instead of array ‘form_id’ => 1, I need something like “Do this” for ALL forms except the ones with ID 1,3,93.

    How can I do this?

    Thank you.

    1. Miguel
      Miguel September 22, 2015 at 8:14 pm

      But I think is not working. I have added this after the snipped:

      [code removed]

      So what I understand with this is that to all the forms when the user (all the users must be connected to send a form) is sending the form he should see that form with the limit_message. However is not happening. I still can send the same form any times.

      What I think should be the correct way for this is just to check in the entries of that form if there is one of the current user and if so show the limit_message. But I don’t understand exactly how is this working.

      Thank you for your fast help!

    1. Fawn
      Fawn September 22, 2015 at 8:39 am

      On GF settings, there is a section for Restrictions/Schedule form where you can schedule a date/time for the form to be active. What I would like to do is have it so the user can submit only 1 entry during that time period for a field that I specify. So under configuration, I would like to set ‘time_period’ to that period of time that the form is active. I have it set for per month right now. This is what I have:

      new GW_Submission_Limit( array( ‘form_id’ => 2, ‘limit_by’ => ‘field_value’, ‘limit’ => array( // “26” is field ID for reviewee, “1” is limit for this field ID 26 => 1 ), ‘limit_message’ => ‘You have already submitted a review this month for this employee. You can only submit 1 review per employee per reporting period.’, ‘time_period’ => per_month // set to false for forever!

    2. David Smith
      David Smith Staff September 22, 2015 at 7:43 pm

      Hi Fawn, currently there is no simple way to achieve this. The snippet does not support limiting between two specific dates, only a time range. I’ve added this to the list of features for the upcoming plugin version of this snippet.

  148. Emily Smith
    Emily Smith August 27, 2015 at 11:46 am

    This code was a major life saver so thank you for posting this. However, after the gravity forms latest update, this code no longer works to limit submissions. They all still appear. I am sure you are aware of this issue but I wanted to post this in case you are not. If you would like to see the page, I will have to create a new one as the current forms are behind the login. Let me know if you would like me to do this.

    1. David Smith
      David Smith Staff September 8, 2015 at 1:38 am

      Hi Emily, I’ve just tested this locally and appears to still be working. Could you share how you have your form configured?

  149. Sainik Biswas
    Sainik Biswas August 6, 2015 at 4:36 pm

    Need Some Help. I have used this configuration for a gravity form I am using

    class GWSubmissionLimit extends GW_Submission_Limit { }


    Basic Usage

    new GW_Submission_Limit( array( ‘form_id’ => 1, ‘time_period’ => ‘per_month’, ‘limit’ => 1, ‘limit_by’ => ‘role’, ‘limit’ => array( ‘administrator’ => 20, ‘contributor’ => 2, ‘subscriber’ => 1 ), ‘limit_message’ => ‘You have already submitted the report for this month. You can only submit the form once in a month.’ ) );

    With this the subscriber can submit the form once, now I want to know whether limiting by per month means. Does it mean the counter will reset every month or will it reset exactly a month from the day the person submitted the form. I need the first option whereby the counter resets 1st of every month, but the subscriber can fill it only once. Can this be done? Loved the snippet, Thanks

  150. Florian Linhardt
    Florian Linhardt July 1, 2015 at 8:17 am

    Hi, I’d love to use this from now on. I will have a lot of forms and checking a box (or two) in the form settings would be much more comfortable than editing the functions.php each time. Is there a chance to have this feature as an installable perk in the near future? Flo

    1. David Smith
      David Smith Staff July 3, 2015 at 12:21 am

      This will be converted (and enhanced) to a perk; however, it’s several months off. It’ll be worth the wait!

    2. David Smith
      David Smith Staff August 3, 2015 at 12:01 pm

      It’s coming, Leho! We’ve got a big perk in the works and this one is next in the queue. :)

  151. Todor
    Todor June 11, 2015 at 8:31 am


    just some thoughts what will be on “Limit by FIeld Value ” if the form have conditional logic. For example: If one have a dropdown with two options A & B. When an user selects A the form loads field Aa, if he chooses B the form loads field Bb.

    So exactly the fields Aa & Bb should limit the form to be submitted more than once.

    I understand that for a single field limit array 2 => 6 works but what happens if there are 2-3 fields that an user switches between.


    1. David Smith
      David Smith Staff June 11, 2015 at 8:37 am

      If you provide multiple fields, it will treat them as a “group”. Only when all fields have the same value as previous submission will the limit be enforced. For example, if you specified a Name field and an Address field to be limited together, only when the same name and same address are provided will this count towards the limit.

    2. Todor
      Todor June 11, 2015 at 11:15 am

      Hello David and thanks for the quick reply. What I mean is not grouping fields but based on conditional logic limitation. For example:

      Dropdown > Option A / Option B If chosen Option A then text field A is shown – this is lets say arrey1 If chosen Option B then text field B is shown - this is lets say arrey2.

      When I add code: limit_array 1=>1 it works for field A but not for field B because there isn`t code that points to it.

      So I tried to add for field B array2 but it isn`t working. And i am curious if it is possible to add one more field .. something like: 1=>1, 2=>1

      Regards, Todor

    3. David Smith
      David Smith Staff June 11, 2015 at 11:48 am

      Hi Todor, currently they only work as a group. It doesn’t support conditional logic in the way you described.

  152. Jason B
    Jason B June 1, 2015 at 10:50 am

    If the default time_period is 24 hours, how do we make it so its by 30 minutes? On top, it says we can do it by minutes but doesn’t explain how.

    1. David Smith
      David Smith Staff June 4, 2015 at 11:10 pm

      Hi Jason, I’ve updated the “time_period” parameter description above and including the addition here:

      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 of 60 * 60 (or 3600) would be one hour.

      30 minutes would be “60 * 30” or “1800”.

  153. Miguel
    Miguel May 22, 2015 at 1:10 pm

    Hello, great code.

    How can I put that if the user role is “example_2” count as 2 people in the limit form instead of 1?

    So if the limit of entries in that form is for example 15 and a user with user role “example_2” send the form the amount available must change to 13 (-2) (instead of 14 (-1) that is the normal way).

    I need to know where in the code execute the subtract to make this conditional.

    Thank you!

    1. David Smith
      David Smith Staff May 22, 2015 at 6:00 pm

      Hi Miguel, this is somewhat involved. I’d recommend hiring a developer to assist with this customization.

    2. Miguel
      Miguel May 25, 2015 at 11:36 am

      The limit_by role is not working in my case:

      Basic Usage

      new GW_Submission_Limit( array( 'limit_by' => 'role', 'limit' => array( 'fanpass' => 1, 'fan-pass-2' => 1, 'administrator' => 1 ), 'time_period' => false, 'limit_message' => 'Enviado' ) );

      I have this code added so I understand that users with roles fanpass, fanpass-2 or admin can send the form only 1 time (each form).

      In my website I have two forms with PayPal that register my users that doesn’t have any limit/is not necessary to be logged in and one of them I see the text “Enviado” even if is don’t sent.

      What I understand with the limit_by role is that ONLY in the forms that i have ticked: “User must be connected” the limit is activated. I can’t include the “form_id” part here because we are going to create a lot of forms so if I add this limit only to those new forms I would need to change the code each time.

      So, I just need this limit to all my forms which my users must be connected to use them.

      Any idea of how can I solve this?

      Thank you!

    3. Miguel
      Miguel May 28, 2015 at 12:53 pm


      thanks that works for me to set the forms I need. However I still have problems with the limit that is not working correctly with my site I dont know why:

      This is now my configuration:

      Basic Usage

      foreach( array( 4, 5 ) as $form_id ) { new GW_Submission_Limit( array( 'form_id' => $form_id, 'limit_by' => 'role', 'limit' => array( 'administrator' => 999, 'fanpass' => 1, 'fan-pass-2' => 1 ), 'time_period' => false, 'limit_message' => '


      ' ) ); }

      And I send the form with my account (admin) without any problem and then I see the limit message. However the limit is not correctly set because I have deleted all the entries in that form and I still see the limit message (even if I change the limit number to 999). I understand that if I delete the entries of the form I should see the input button again working instead of the limit_message.

      I have tried to clear cache of my browser but still not working. I need that if the form is sent the user must see the limit_message (ok) but If we delete that entry of the form, the user should be able to re-sent that form because we have deleted the entry.

      Any idea? Thank you!!!

    4. David Smith
      David Smith Staff May 29, 2015 at 6:34 pm

      Some things to check on:

      1. Try with a single form first and make sure that is working.
      2. Confirm your role names are correct.
      3. Make sure you’re using the “raw” version of the snippet (via “Download Code” button).
  154. Joe
    Joe May 3, 2015 at 10:01 pm

    Hi! When I place this code in my theme’s functions.php file the site will not load.

    new GW_Submission_Limit( array( ‘form_id’ => 2, ‘limit_by’ => ‘user_id’, ‘limit’ => 1, ‘time_period’ => ‘per_day’ ) );

    I tried removing the ?> at the end of the file but that didn’t work either. Can you help? I have the latest version of gravity forms installed.

  155. Scott Stewart
    Scott Stewart March 20, 2015 at 5:25 pm

    I like the extendability of this snippet. I was wondering if there was a way to limit after a certain event has occurred. For example, I have them fill out a gravity form and then that accesses a screen where they fill out more information. I don’t want to block them if they leave the second screen, but I do want to stop them from entering information on the first screen if they fill out the second screen.



    1. David Smith
      David Smith Staff August 4, 2015 at 7:32 pm

      Hi Scott, your comment got lost. Sorry, about that. There are two ways to accomplish this. Both require custom code. If the user is not logged in, you’ll need to use cookies to remember their progress. If the user is logged in, you can store their progress in the user meta.

  156. Damien
    Damien March 20, 2015 at 9:31 am

    Hi guys ! Thanks for this awesome tutorial. I’m making a contest site, I used it in order to allow members to post a CPT only one time. But do you know if with this plugin I can allow members to edit the CPT they posted ? Best Regards Damien

  157. Fred
    Fred March 4, 2015 at 6:25 am

    Hello, Thank you very much for your snippet. I have a question : I’ve tested some usages limitations with a test user. Is there a way to clear his history ? I’ve deleted recorded messages, but the limitation is still active. TY !

  158. irfan
    irfan February 20, 2015 at 6:00 am


    You guys are just superb!!, i am having one problem, i am trying to pass three fields with different ID’s with limit to 1 in one day.. below is my code.. but its not working.. is this the right way.. please help!!


    new GW_Submission_Limit( array( ‘form_id’ => 1, ‘limit_by’ => ‘field_value’, ‘limit’ => array( // “2” is your field ID, “6” is your limit for this field ID 24 => 1, 25 => 1, 26 => 1 ),

    'time_period' => 'per_day'

    ) );

    1. irfan
      irfan February 20, 2015 at 7:28 am

      Thanks for the reply..

      Strange its working with 1 id, but not working with multiple ids.

      Ok let me check again.. another quick questions..

      let say i am using one field to limit to 1. On form load, is there any wat that the field is in disable mode or with some red color after its reaches the limit..

      Once again thanks…

    2. David Smith
      David Smith Staff February 20, 2015 at 8:17 am

      Hi Irfan, removing or disabling the choice when the limit is exhausted is supported with GP Limit Choices. I think based on what you’re trying to do, the plugin will be a lot easier to use and the snippet I shared with you will allow you to apply the daily limit. I’m not just trying to upsell you. I really do think it’s the best choice for this functionality. :)

  159. Erin
    Erin February 17, 2015 at 1:40 pm

    For some, I added this code to my Functions.php

    It breaks my site…blank screen. I only made the following changes to the code

    new GW_Submission_Limit( array( ‘form_id’ => 3, ‘limit’ => 1, ‘limit_message’ => ‘Please try again in 24 hours’ ‘limit_by’ => ip, ‘time_period’ => ‘per_day’ ) );

    Any ideas? I removed the opening <?php> tag. There is no closing tag. Sorry…I am not a php master and I can’t see the issue.

  160. James
    James February 10, 2015 at 4:07 pm

    This code won’t work for me under a certain condition. I am actually embedding 7 forms in one page for a voting mechanism (and, yes, I have problems with the wisdom of this too, but not something I can change at the moment). Unfortunately, I’m up against finding a solution for this today.

    The goal is to restrict users by IP to voting on each contest only once, so that I’d only get the restriction notification on the form(s) I already voted on, if I came back to the page to vote again in the timeframe. For testing purposes, I’m only setting a limit on one of the forms. However, when I test that form, it applies the restrictions to all the others.

    In other words, if I test vote on any of the forms I haven’t specified, I don’t get any restrictions, as expected. When I test vote the one I have restricted (id=8), it stops me from voting on any of them, so it’s not respecting the form ID. I have it set to 120 seconds so I can test easily repeatedly.

    Originally, I wanted to use an array of form IDs, but that doesn’t appear to be supported. However, at present, I can’t even set limits to more than one form, since once the first one is submitted, it’s blocking all of them.

    These are my usage parameters:

    new GW_Submission_Limit( array( 'form_id' => 8, 'limit_by' => 'ip', 'limit' => 1, 'time_period' => 120, 'limit_message' => 'It appears you have already submitted this form. Only one vote is allowed per contest.' ) );

    1. David Smith
      David Smith Staff February 10, 2015 at 11:44 pm

      Hi James, I’ve just updated the snippet so only the form that is limited should be configured. You will still need to provide individual configurations for each form you wish to limit.

    2. James
      James February 11, 2015 at 11:42 am

      Thanks for the quick update David. Since I had to get client signoff I was forced to break things into separate forms this time, but can definitely see other times when this will be a useful update. I noticed some of your other snippets do allow form ID arrays. That would be really useful and keep the code size down.

      I’m really surprised that form submission limit by IP isn’t a feature built into GF. It’s a fairly glaring gap.

  161. Femke Rosiers
    Femke Rosiers January 26, 2015 at 8:35 am

    Hello David

    We have a question about Snippet Limit submissions The product we sell through gravity forms are seminars and the product choices are the different dates the seminars are held. And according to the date of the seminar, the number of available seats changes (different meeting rooms). How exactly can we limit submissions per product choice?

    Thanks in advice for your help,


  162. Patrick
    Patrick January 9, 2015 at 12:43 am

    Does this limit by ip of the individual computer or by the outbound modem ip. In a company could each computer do it once or only one person in the company behind the modem?

    1. David Smith
      David Smith Staff January 9, 2015 at 8:42 am

      Hi Patrick, this is based on the public IP which typically is the same for any devices connecting to the Internet through the same modem. So within a company, limiting by IP with this snippet, would not be very usable.

  163. Jonathan
    Jonathan November 20, 2014 at 9:12 am

    Awesome Snippet! Just wanted to verify, if I wanted to limit submission to one a day per logged in user, I would do the following:

    new GW_Submission_Limit( array( 'form_id' => 3, 'limit' => 1, 'time_period' => 'per_month', 'limit_by' => 'user_id', ) );

  164. Sabbella
    Sabbella November 19, 2014 at 7:45 am


    I’m using wordpress 3.3.2 and Gravity Forms 1.6.5 and I can’t update them right now.

    I need a code that makes this function on my site:

    “Limit the number of a submissions a logged in user can make to specific form from the same embed URL. This would allow you to embed the same form on multiple pages and allow users to submit that form up to the submission limit on each page.”

    This code (valid if wordpres and Gravity Forms are updated) breaks my site:

    new GW_Submission_Limit( array( ‘form_id’ => 2, ‘limit’ => 1, ‘limit_message’ => ‘Aha! You have been limited.’, ‘limit_by’ => array( ’embed_url’, ‘user_id’ ) ) );

    Is there a way to do it? I would pay for this job.

    Thank you, Sabbella

  165. Sabbella
    Sabbella November 19, 2014 at 7:19 am


    I’m using wordpress 3.3.2 and Gravity Forms 1.6.5 and I can’t update right now. I need this code -or another- that makes this function on my site:

    “Limit the number of a submissions a logged in user can make to specific form from the same embed URL. This would allow you to embed the same form on multiple pages and allow users to submit that form up to the submission limit on each page.”

    new GW_Submission_Limit( array( ‘form_id’ => 2, ‘limit’ => 1, ‘limit_message’ => ‘Aha! You have been limited.’, ‘limit_by’ => array( ’embed_url’, ‘user_id’ ) ) );

    Is there a way to do this? I would pay for this job.

    Thank you, Sabbella

  166. Jamie Larson
    Jamie Larson November 10, 2014 at 5:02 pm

    I’m looking for a little more than the snippets listed. I’m trying to limit the submissions to only 4 per person. There may be more people at the same IP Address, so that cannot be used as a delimiter. Is there a way to adapt this snippet to do the following:

    If Last Name field matches any of the last names already entered, and the First Name field matches any of the first name fields entered, and the Zip code field matches any of the zip code fields, on the 5th time these all match, deliver an error message.