October 21, 2013: Added "format" parameter which supports either a "comma" or "decimal" value for formatting the number of entries left.
I’ve had many users ask me about this since I published the Display Number of Entries Left… snippet back in April. I wrote a follow up article which demonstrated how to display this entry limit in the sidebar. Special thanks to Ty who pointed out this would be much better served as a shortcode.
After installing this snippet, you will be able to retrieve your form’s entries left with the following shortcode:
[gravityforms action="entries_left" id="your_form_id"]
How do I install this snippet?
Easy peasy. Just copy and paste the code above into your theme’s functions.php file.
How do I use this shortcode?
Very carefully. I’m kidding. Fire at will. Just enter your form ID and the shortcode will return the number of entries left.
The Shortcode
[gravityforms action="entries_left" id="your_form_id"]
Example
[gravityforms action="entries_left" id="2"]
How’d we do?
If you use it and like it, let us know. We’d love to hear the different ways you found this code useful!
Continue Reading about Shortcodes
If you’re looking for more information about Gravity Forms shortcodes — including all the different types, shortcode parameters, and how to get started using each, check out our comprehensive guide on Gravity Forms Shortcodes.
Did this resource help you do something awesome with Gravity Forms?
Then you'll absolutely love Gravity Perks; a suite of 47+ essential add-ons for Gravity Forms with support you can count on.
How do I style only the “entries left” line since it’s added in the lable tag? Thanks :)
Hi Tim,
Depending on how you’re using the shortcode, you can wrap a span tag around it and use inline CSS to style it
Best,
Thanks so much for this snippet! Has been a huge help for setting up a volunteer registration system. Is there an easy way to also display the total number of available entries? For example: “5 out of 20 spots available”
Hi Mark,
Show the spots left would require a bit of customization. You could probably try using Gravity Forms Limit Submissions or GP Inventory which don’t require any custom code!
Best,
nice code, but when i use this shortcode what get php error. ‘Notice compact(): Undefined variable: is_default’
how can i fix it?
Hi,
I was able to reproduce a similar issue locally. I’ll ping our dev team about this issue.
Cheers,
Hi, it’s possible to to link the number to purchases actually made? thiis parameter “approved_payments_only”
Hi Mauro,
Currently, this is not supported from what I understand but this snippet could work for you Gravity Forms Progress Meter
If you have an active Gravity Perks License, you can get in touch with us via our support form so can dig into this.
Cheers,
Great snippit and very helpfull to use!! Although I do have a bit of a problem.
The snippit works great while visiting the site with chrome, but doesn’t work while visiting the site with firefox or edge.
Any clue where to solve this?
Hello Barry, This is a bit of a strange one. When attempting to recreate this issue, I was unable to. Could you send us a link to the form in question so we can see what you see. Thanks! 😀
Solved, It seems that it was somehow related to some cache settings on the site.
Hi David, How are you? Is there a way to show only a single entry? In other words I want to show the total count but I also want to show how many clicks was made on a single poll.
Hi Michelle, we don’t have a solution for this one.
Love this code!
Have a question. I want to use this for workshops with limited places (12). But 1 entry can contains 1 or more participants. So for example: 3 entries with 4 participants each can fill the workshop and I need this in the code. Any suggestions?
And if this is possible an additional question. Can the count entries left also be shown in the form where the person who’s entering the entry can choice how many people he/she wants to subscribe? So, when there are for example 3 places left in a workshop and someone want to subscribes a few persons he/she sees that 3 is the maximum.
I would very much appreciate your answer.
Thanks in advance.
Regards,
Jorrit
Hi Jorrit, this sounds like a better fit for our Better Inventory snippet (which also supports it’s own shortcodes for showing remaining counts).
https://gravitywiz.com/better-inventory-with-gravity-forms/
Thanks! That looks promising, particularly in a situation in which the same registration form handles multiple events. Although I’m guessing it may not disallow registration of an event that’s full?
If you want to get into limiting the form based on “inventory”, this is probably the preferable solution.
https://gravitywiz.com/better-inventory-with-gravity-forms/
It also has several shortcodes for displaying the inventory left. The documentation for these blows but you can find the important details in my response to another user here:
https://gravitywiz.com/better-inventory-with-gravity-forms/comment-page-6/#comment-291178
A few more details on how you’d make this work for multiple events…
BTW, I reviewed Perks, and didn’t find an indication this functionality is included.
This is a great idea and easy implementation, but useless with say, a registration form if it handles a series of events. Unless(!) there is a way to reset the count; then it’s truly great.
I notice the author indicates in December 2015 that he could provide this solution to a commentor for payment. Any chance a simple solution for resetting could be published here to make this a more complete solution? Or perhaps there is a plugin now that includes that capability? I’d buy the plugin.
HI Ray, you might consider GF Chart for displaying a filtered count.
Thanks! I’m using Twig/Timber. The shortcode function only works when I put it inside TimberSite construct function where I have all the “add_filter” lines. Not sure why but it just works.
Interesting solution. Glad you got it working. :)
Hi, urgent help needed. Is there a way to set the limited selection counter to a radio button field. Details below: Is there a way to restrict specific radio button field(s) within the form to a limited number of selections like a countdown from X to zero. After the counter (number of predefined selections) reaches zero the field should be disabled (unavailable) for all other visitors that come later to make a selection.
Example: Select your teacher: _ Roy (10 classes left) _ Mark (3 classes left) _ Damon (0 classes left) (unavailable, not visible to the visitors anymore)
URGENT solution needed, thank you.
This plugin is what you need: https://gravitywiz.com/documentation/gravity-forms-limit-choices/
I want to show checkbox (checked) count after submission.. I want a shortcode for this to generate checkbox number.
Hi Shemul, you could use this snippet to store the selected count in a field and then use the merge tag for that field to display the count wherever: https://gist.github.com/spivurno/077fd21a993e9b573d46
Hi GravityWiz. This works well…to an extent. It doesn’t reset. I have my forms limited to 25 entries a day, I’ve submitted on the form once and every day since the count stays at “24 entries left”. Any ideas? Thank you.
Hi Joy, you are correct. Would you like to commission this enhancement? If so, get in touch.
When I paste this code into my functions.php file I get the white screen of death and an error “[02-Oct-2015 17:54:49 UTC] PHP Parse error: syntax error, unexpected ‘<‘ in /home2/journfz6/public_html/wp-content/themes/journey/functions.php on line 931”
Can you help?
Running PHP 5.4
Hi Josh, take a look at this help doc and let me know if your issue persists: https://gravitywiz.com/documentation/snippet-troubleshooting/
Hi, I have a dropdown with 3 LIMITED choice (5 times limit for each choice) and I would like to SHOW the number of times remaining next to each choice of the dropdown… can you help?
Hi Derek, are you using GP Limit Choices? If so, you can display a message next to each choice with the following snippet: https://gist.github.com/spivurno/7858140
Hi I wanted to know is there a way to have a countdown link to an entry in a gravity form?
Hey Jeremy, not sure I understand your question. Could you elaborate?
Hi
What I mean is there are countdown plugins – etc birthday and I wanted to know how i could have that take the date of someone’s profile automatically from a gravity form?
Would it be down to the countdown plugin?
Sorry, Jeremy. Still not following. Are you asking if it’s possible to use Gravity Forms as a countdown plugin or do you want to use data submitted via a Gravity Forms in a 3rd party countdown plugin?
Hello,
I need to subtract 2 instead of 1 if the user role is one specific. I think I can get into this in 2 ways:
Adding a conditional of that role in functions so I can just subtract 2 instead of 1 but I didn’t find the way to do this.
Adding a conditional so when a user with that role send the form the entry is added 2 times to the DB directly.
I have tried to add conditional statements to the form using “quantity” but this is not related with the number of entries so is not working.
I saw in the forms_model where is taking the number but I don’t really know how to apply this conditional correctly.
Any idea or tip of how can I get into this?
Thank you!
Hi Miguel,
I would recommend hiring a developer to assist with this customization. Codeable.io or WP Curve are two great options.
Bro how can i add php or tweak i would like to display counts only for the current user example when they are logged in i just added your code on my function.php can you help me
thank you
Hey Jasper, this is not readily possible with this snippet. Get in touch if you’re interested in hiring me to write this.
Hi there,
Great work and many thanks for all the PERK’S , will be purchasing within the next week.
I have a question in regard to the using the Display entries left snippets.
Wondered how they can be coded to display the amount of entries left specified using your other snippet –
” Better Limit Submission Per Time Period by User or IP” https://gravitywiz.com/better-limit-submission-per-time-period-by-user-or-ip/comment-page-2/#comment-155605
IE. that way if limited by IP or User ID will display different amounts of entries left.
I have only been able to get it to show the limits set in the gravity forms settings so far.
Cheers and thanks again, awesome work.
Hi Marcus, this would require some custom code. Get in touch if you’re interested in commissioning it.
Hey, Thanks for the reply,
Will contact you you via the link.
Cheers.
Many thanks for this snippet code. I am using it on a client site (link supplied), and am using the code to let people know how many spaces are left for a workshop. It is working great on all but one of the forms, and as far as I can see, there is no difference in the set up of this particular form.
The issue is that on this one form, even though there are only 6 out of the maximum 8 entries used, the “Entry Limit Reached Message” is showing.
My Shortcode are set up as follows:-
There are currently [gravityforms action="entries_left" id="13"] spaces left on this workshop. [gravityform id="13" name="Workshop - Sunday 8th March 2015" title="false" description="false" ajax="true"]
I also added the “Display Number of Entries Submitted” shortcode and it shows the fact that there are 6 entries and not 8.
[gravityforms action="entry_count" id="13"]
I’m confused as to why that might be. Do you have any ideas?
Thank you.