Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    • Documentation
    • Support
    • Account

Shortcode: Display Number of Entries Left

This shortcode extends the [gravityforms] shortcode, providing a custom action to retrieve the number of entries left based on the form's entry limit.

Last updated December 13, 2021 | Written by David Smith 93 Comments

  • October 21, 2013: Added "format" parameter which supports either a "comma" or "decimal" value for formatting the number of entries left.

Looking for a way to display the number of entries submitted? We’ve got a shortcode for that too!
View CodeDownload Code

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.

Would you like to use this shortcode in the sidebar of your website? Check out the Shortcode Widget plugin!

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!

Did this resource help you do something awesome with Gravity Forms? Then you'll absolutely love Gravity Perks; a suite of 41+ essential add-ons for Gravity Forms with support you can count on.

  • View All Perks
  • Buy Gravity Perks

Filed Under: Snippets

Comments

  1. Tim says

    April 7, 2022 at 3:09 am

    How do I style only the “entries left” line since it’s added in the lable tag? Thanks :)

    Reply
    • Samuel Bassah says

      April 7, 2022 at 6:13 am

      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,

  2. Mark Hewes says

    March 14, 2022 at 5:37 pm

    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”

    Reply
    • Dario Space says

      March 14, 2022 at 6:36 pm

      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,

  3. fungwong says

    December 13, 2021 at 12:51 am

    nice code, but when i use this shortcode what get php error. ‘Notice compact(): Undefined variable: is_default’

    how can i fix it?

    Reply
    • Dario Space says

      December 13, 2021 at 8:08 am

      Hi,

      I was able to reproduce a similar issue locally. I’ll ping our dev team about this issue.

      Cheers,

    • Mauro says

      January 17, 2022 at 8:58 am

      Hi, it’s possible to to link the number to purchases actually made? thiis parameter “approved_payments_only”

    • Dario Space says

      January 17, 2022 at 9:35 am

      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,

  4. Barry says

    September 23, 2020 at 1:20 pm

    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?

    Reply
    • Ryan Donovan says

      September 23, 2020 at 1:50 pm

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

    • Barry says

      September 23, 2020 at 2:55 pm

      Solved, It seems that it was somehow related to some cache settings on the site.

  5. Michelle Jooste says

    December 5, 2018 at 5:15 am

    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.

    Reply
    • David Smith says

      December 5, 2018 at 8:00 am

      Hi Michelle, we don’t have a solution for this one.

  6. Jorrit says

    November 21, 2018 at 6:58 pm

    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

    Reply
    • David Smith says

      December 1, 2018 at 9:35 am

      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/

  7. Ray Gulick says

    January 22, 2018 at 4:37 pm

    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?

    Reply
    • David Smith says

      January 22, 2018 at 8:46 pm

      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

    • David Smith says

      January 22, 2018 at 8:49 pm

      A few more details on how you’d make this work for multiple events…

      • If the events are a post type, you can populate the inventory parameter from a custom field for the current event. This would allow you to set the inventory on each event post.
      • You’ll want to take advantage of the “field_group” parameter which would allow you make your quantity field specific to the value populated into another field. In this case you’ll want to populate that field with the post ID of your event.
  8. Ray Gulick says

    January 22, 2018 at 3:43 pm

    BTW, I reviewed Perks, and didn’t find an indication this functionality is included.

    Reply
  9. Ray Gulick says

    January 22, 2018 at 3:20 pm

    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.

    Reply
    • David Smith says

      January 22, 2018 at 4:18 pm

      HI Ray, you might consider GF Chart for displaying a filtered count.

  10. Will says

    January 4, 2018 at 10:04 am

    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.

    Reply
    • David Smith says

      January 6, 2018 at 2:13 pm

      Interesting solution. Glad you got it working. :)

  11. Marin says

    November 29, 2017 at 5:57 am

    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.

    Reply
    • David Smith says

      November 29, 2017 at 7:54 am

      This plugin is what you need: https://gravitywiz.com/documentation/gravity-forms-limit-choices/

  12. shemul says

    November 29, 2016 at 4:16 pm

    I want to show checkbox (checked) count after submission.. I want a shortcode for this to generate checkbox number.

    Reply
    • David Smith says

      November 30, 2016 at 9:13 am

      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

  13. Joy says

    December 21, 2015 at 6:50 pm

    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.

    Reply
    • David Smith says

      December 23, 2015 at 7:37 am

      Hi Joy, you are correct. Would you like to commission this enhancement? If so, get in touch.

  14. Josh says

    October 2, 2015 at 2:13 pm

    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?

    Reply
    • Josh says

      October 2, 2015 at 2:14 pm

      Running PHP 5.4

    • David Smith says

      October 2, 2015 at 11:57 pm

      Hi Josh, take a look at this help doc and let me know if your issue persists: https://gravitywiz.com/documentation/snippet-troubleshooting/

  15. derek Morin says

    September 14, 2015 at 2:24 pm

    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?

    Reply
    • David Smith says

      September 19, 2015 at 7:32 pm

      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

  16. jeremy says

    September 12, 2015 at 10:55 pm

    Hi I wanted to know is there a way to have a countdown link to an entry in a gravity form?

    Reply
    • David Smith says

      September 12, 2015 at 11:59 pm

      Hey Jeremy, not sure I understand your question. Could you elaborate?

    • Jeremy says

      September 13, 2015 at 9:06 am

      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?

    • David Smith says

      September 14, 2015 at 10:39 pm

      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?

  17. Miguel says

    May 29, 2015 at 7:15 am

    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:

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

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

    Reply
    • David Smith says

      May 29, 2015 at 6:08 pm

      Hi Miguel,

      I would recommend hiring a developer to assist with this customization. Codeable.io or WP Curve are two great options.

  18. jasper says

    February 28, 2015 at 11:36 am

    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

    Reply
    • David Smith says

      March 2, 2015 at 4:41 pm

      Hey Jasper, this is not readily possible with this snippet. Get in touch if you’re interested in hiring me to write this.

  19. Marcus says

    December 9, 2014 at 11:06 pm

    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.

    Reply
    • David Smith says

      December 10, 2014 at 8:40 am

      Hi Marcus, this would require some custom code. Get in touch if you’re interested in commissioning it.

    • Marus says

      December 10, 2014 at 4:32 pm

      Hey, Thanks for the reply,

      Will contact you you via the link.

      Cheers.

  20. Craig says

    November 18, 2014 at 5:35 pm

    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.

    Reply
« Older Comments

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Recent Posts

  • How ANM Powers Internal Finances with GP Unique ID
  • New Release: Gravity Forms QR Code Beta 1
  • How Farbie.at uses GP Inventory to manage over one thousand parties a year
  • Spotlight: Building a Loan Calculator with GP Advanced Calculations
  • Gravity Forms Email Validation: Check Emails Live Prior to Submission

Categories

  • How To (73)
  • News (25)
  • Plugins (19)
  • Releases (13)
  • Resource (3)
  • Snippets (50)
  • Spotlights (14)
  • Tutorials (57)
  • Uncategorized (4)
  • Updates (152)

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2022 · Powered by WordPress · Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Terms & Conditions of Use
  • Privacy Policy
  • Cookies Policy

Want to become a
Gravity Forms wizard?

Join 15,000 readers and be the first to know of legendary discounts, new releases, free snippets, and other secret sorcery!

Download Snippet

Shortcode: Display Number of Entries Left

  • Gravity Perks
    ▼
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    ▼
    • Documentation
    • Support
    • Account