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.

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!

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!

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.

Comments

  1. Andre
    Andre September 29, 2023 at 8:24 am

    Hello,

    nice feature to show the remaining amount of form submissions left. It works perfectly. However, is there a way to add some custom text before and/or after the counter?

    So that for example, it will say: XXX submissions remaining.

    Cheers in advance.

    Andre

    Reply
    1. Scott Ryer
      Scott Ryer Staff September 29, 2023 at 4:28 pm

      Hi Andre,

      You can add your custom text before or after the shortcode wherever you decide to place it. Rough example:

      Submissions Remaining

  2. Tania
    Tania September 8, 2023 at 10:01 am

    Helloooo :-)

    I have installed the snippet and it works ! However, I have several reccurring events, created seperately and the snippet indicates the total of registries. Let me explain further :

    1/ I have 4 events , Monday, Tuesday, Wednesday and Thursday. 2/ Each of them have a max entries of 48. 3/ John booked Monday, and Mary booked Thursday (= minus 2 entries) 4/ ALL my 4 entries show 46 (which is 48-2).

    Why de deduction is not made on the day registered only ? Which should be MON 47, TUE 48, WED 48 and THU 47 ?

    Thank you for your Help in this :-)

    Tania

    Reply
    1. Scott Ryer
      Scott Ryer Staff September 8, 2023 at 2:05 pm

      Hi Tania,

      I think that is a better fit for GP Inventory. It lets you set limits on the individual items and/or dates on your form. You can then display the number remaining, and with scoped inventory that number is context aware of the current selections in the form.

  3. etc2022
    etc2022 November 15, 2022 at 12:27 am

    Greetings great! the question is can filter the count according to members or users, ie showing the count for each user seperatedly. Regards

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff 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,

  4. Mark Hewes
    Mark Hewes 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
  5. fungwong
    fungwong 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
    1. Dario Space
      Dario Space 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,

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

  6. Barry
    Barry 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
    1. Ryan Donovan
      Ryan Donovan 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! 😀

  7. Michelle Jooste
    Michelle Jooste 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
  8. Jorrit
    Jorrit 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
  9. Ray Gulick
    Ray Gulick 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
    1. David Smith
      David Smith Staff 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.
  10. Ray Gulick
    Ray Gulick 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
  11. Will
    Will 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
  12. Marin
    Marin 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
  13. Joy
    Joy 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
  14. Josh
    Josh 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
  15. derek Morin
    derek Morin 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
    1. Jeremy
      Jeremy 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?

    2. David Smith
      David Smith Staff 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?

  16. Miguel
    Miguel 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
  17. jasper
    jasper 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
  18. Marcus
    Marcus 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
  19. Craig
    Craig 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
  20. Trent
    Trent November 5, 2014 at 8:02 pm

    Hi David,

    First off, thank you for this. Second, Iv’e seen that you’ve done much with displaying the amount of entries left, the entry count, etc….My question is, do you happen to know how I would go about getting a rounded up percentage of entries available based on the entry limit compared to the entry count? I.e The Count divided by the total and displayed as a full percentage? I know that this question isn’t specifically related to your post, but thought I’d try. Thank you in advance!

    Reply
  21. yves
    yves October 20, 2014 at 12:26 pm

    Hello David,

    Do you think it is possible to do the following :

    If number of remaining entries equals zero, then make the posts in which the form is embedded private?

    Right now, I would just like to know if possible – later I will ask you for a quote for this snippet.

    Kind regards,

    Yves

    Reply
    1. David Smith
      David Smith Staff October 20, 2014 at 3:03 pm

      Yes, this is possible. Is there a specific reason you would need to hide the page itself rather than just the form via GF’s default limit entries functionality?

    2. Chris
      Chris November 3, 2019 at 9:21 am

      Hello Yves,

      I love such concepts, and i will prefer the post hidden rather than the form itself, reasons are posts have categories and navigation but forms do not have. I will like to know how to archive this function.

  22. Marc Ryder
    Marc Ryder October 17, 2014 at 5:58 am

    Thanks David,

    I am using a number of forms on the same site, each with a limit of entries. How do I get the shortcode snippet to return the correct entry for the particular form

    Thanks in advance Marc

    Reply
    1. David Smith
      David Smith Staff October 17, 2014 at 6:19 pm

      Hi Marc, not sure I understand. Pass the form ID to get the entries left for that form. You can use the shortcode multiple times, each with a different form. Does that answer your question?

    2. Marc
      Marc October 18, 2014 at 1:01 am

      Thanks so much for getting back to me. I am a total hack when it comes to php. I am sure what I am asking should be known by anyone with basic skills, so pls forgive the question. I wouldn’t be offended if you told me to go back to school:)

      I have multiple forms each with a limited number of entries set. I would like to display the Entries left for each form. By adding the form ID ( in this case 5) to the code line number 17. So $form = RGFormsModel::get_form_meta( $id ); becomes $form = RGFormsModel::get_form_meta( $id =5); it returns the Entries left correctly for form 5.

      What do I need to change to get forms ID 7, 8 & 9 to display correctly

      Thanks again in advance

    3. David Smith
      David Smith Staff October 18, 2014 at 5:58 am

      You would use:

      [gravityforms action="entries_left" id="7"]
      [gravityforms action="entries_left" id="8"]
      [gravityforms action="entries_left" id="9"]

  23. concerto
    concerto October 8, 2014 at 1:23 pm

    hi

    this is a great little snippet as are some of the perks which we recently purchased

    i have a question about the count itself. we have an event that can hold 400 people and we need to be able to count to that figure.

    we have set up the form to have a simple are you taking a guest YES/NO radio button followed by further questions based on the initial option

    the issue i have is if for example 200 people are invited and each takes a guest then that is fine and the number of entries left is displayed properly and we can limit the form at that – 200 entries and know that possibly that will be 200*2 which will give us our total number

    as it stands if some people are not taking a guest, how do we determine the actual amount of available ‘entries’ left?

    say 150 people are taking a guest and 50 are not then technically speaking that is only 350 ‘guests’ with 50 more than can come. hopefully that makes sense… it confused me when i read it back the first time ;p

    is there a way gravity forms can actually do this – sorry bit of a novice

    any help appreciated

    cheers

    Reply
    1. David Smith
      David Smith Staff October 9, 2014 at 3:09 am

      First, thanks for being a Gravity Perks customer! It really does help keep the lights on here. :)

      There isn’t a super straight forward way to handle this. The basic premise is that the entry itself would count for one “spot” and the additional guest would count as another “spot”. This is possible but would require some custom code to achieve. If you’re interested in commissioning me to write this code for you, I’d be happy to offer you a discount since you’re a Gravity Perks customer.;)

      Get in touch if you’re interested.

    1. David Smith
      David Smith Staff October 5, 2014 at 7:51 am

      Hey Yves, GF notifications support shortcodes. You can add this shortcode right into the notification message.

  24. mili
    mili September 4, 2014 at 9:13 am

    Hi David, Is there anyway to display the number of total entries? something like: “XXX people submitted this form”

    [gravityforms action="entries_count" id="your_form_id"]

    Reply
    1. David Smith
      David Smith Staff September 4, 2014 at 11:18 am

      Hi Mili, here is a snippet that adds support for an “entry_count” action on the [gravityforms] shortcode.

      https://gist.github.com/spivurno/afac61057595ea9c625a

      Usage would look like this:

      [gravityforms action="entry_count" id="12" /]

      It also supports retrieving the count by status (i.e. “trash”, “starred”, “unread”, “spam”).

      [gravityforms action="entry_count" id="12" status="unread" /]

  25. Jesse
    Jesse March 19, 2014 at 5:44 pm

    This is a great snippet. Really helped me out with a project I’m working on. Works beautifully.

    Question though…we want to create a form with a countdown to a certain number of signups (just like this shortcode would allow), but we want the count to reset after the number of entries is complete and continue to allow entries.

    Do you have any suggestions on how we might accomplish this? I’m not sure if it’d be best to ditch the entry limit entirely and try to create some other kind of counting function and modify your shortcode to track it…or if there’s someway to swap the form for another once the maximum entries have been reached.

    I’d really appreciate your expert advice. But in anycase, thanks again for a great snippet.

    Reply
    1. David Smith
      David Smith Staff March 20, 2014 at 8:08 am

      Hi Jesse, here is some basic code to get you started. The concept is that there is no configured entry limit. You specify the “cap” in the code and then it will “reset” the counter every time the cap is reached. For example, if there are 2 entries and the cap is 60, there are 58 submissions left. If there are 62 entries and the cap is 60, there are 58 submissions left. Make sense?

    2. Jesse
      Jesse March 20, 2014 at 3:58 pm

      Nevermind, figured out a method to do this…just modified your shortcode to remove the checks for limitEntries, created a variable that holds the entry count rounded up to the nearest hundred and return this variable minus the entry count. So now it always counts down from 100 entries.

      But now I have another question…can you think of any way you could conceivably display the count in real time? So if someone submits an entry while you’re viewing the page the number actually updates?

      I’m guessing this is near impossible without modification, as I don’t know how the gravity forms PHP could pass this value in real time, but if you can think of a way I’d love to hear it and try it out. Thanks again.

    3. Jesse
      Jesse March 20, 2014 at 4:04 pm

      Sorry, didn’t notice you’d replied to my first comment…would’ve thanked you instead of saying nevermind. I really appreciate the assistance.

      No need to approve this comment, just didn’t know how else to reach you.

  26. Corbin
    Corbin March 13, 2014 at 5:37 pm

    Think there’s any chance something like this could work in hand with Better Inventory to show how many products are left.

    In my scenario products are tickets, and we have a limited number of tickets and would love to show the inventory instead of entries, as each entry can have several tickets purchased within it.

    Great snippet though! Thanks again

    Reply
    1. David Smith
      David Smith Staff October 21, 2013 at 2:51 pm

      Hi Samantha, I’ve updated the snippet above to support a “format” parameter on the shortcode. Example: [gravityforms action="entries_left" id="369" format="comma"]

  27. don
    don June 28, 2013 at 5:29 am

    Hi David

    That is really a great code! Thanks a lot and we modified it also to a total entries / available entries and entries left.

    Now we would like to have an overview for all of over events. How can we manage this code to show it in a listable view, without to add the code for each events? It should automatically search the forms based on a tag oder categorie. for Example: event 1 : 100 / 50 / 50 event 2 : 100 / 30 / 70

    Reply
  28. don
    don May 30, 2013 at 8:26 am

    Hi David

    Is there a way to enhance this great plugin for a list of forms. We have several forms, one per event. Now I would like to show all entries left in one list every event on a single line (with name, entries left).

    Reply
  29. Amber
    Amber May 25, 2013 at 1:52 pm

    Hey there! Great snippet. Is there a way to make it so I could have my 3 volunteer positions and the entries left beside them? As opposed to the entries left above the form itself.

    Reply
    1. David Smith
      David Smith Staff May 27, 2013 at 8:08 am

      Hi Amber, you can use this shortcode anywhere in your post content. Not sure how your content is setup but assuming you are outputting some content for each volunteer position, just add this shortcode after each position and style as needed. Let me know if I haven’t understood correctly.

  30. Mike
    Mike March 18, 2013 at 2:13 pm

    I am excited to get this working. Looks like its just what I needed. I pasted the code into my functions.php file at the very end. When I use the short code I get the actual form itself and not the remaining entries. I have verified correct form ID, entries limited is set in the form settings. Did I possibly paste the code in the wrong place within the functions.php file? Thanks for any help you can offer.

    Reply
  31. ronald
    ronald January 4, 2013 at 2:50 am

    I am looking for shordcodes which show the entry lists, not the form. originally,gravityform plugin shows the entries lists in Admin Panel, but I want to display the entries at the front page. if you could help thanks in advance

    Reply
  32. Alex
    Alex November 28, 2012 at 10:40 pm

    THANK YOU!!!! I have been looking for this all over and just stumbled upon this page. IT WORKS!! :) I can not believe a plugin this big(over 400k sold) would not have a option to retrieve data and use boolean strings…

    So thank you very much for this. :)

    Reply
  33. H.Kim
    H.Kim November 9, 2012 at 7:58 pm

    Thank you very much, David! :)

    Hm… it worked well but after I deleted some entries, the counter is fixed on the maximum number of entries defined within the Gravity forms…

    Reply
    1. David Smith
      David Smith Staff November 9, 2012 at 8:26 pm

      Good catch, Kim. There was a small bug where it was also counting entries in your trash. I’ve updated the code to only count “active” entries towards the entry limit. :)

    2. Gary Samuels
      Gary Samuels September 12, 2013 at 5:19 pm

      Thanks for the great snippet! I’ve added the code above but it looks like it’s still counting entries in the trash. When my form limit was meet it worked as it should but after deleting the entries the form would not return/display. I had to empty the trash before it started working again.

      the php i’m using contains: $entry_count = RGFormsModel::get_lead_count($form[‘id’], ”, null, null, null, null, ‘active’);

    3. David Smith
      David Smith Staff September 12, 2013 at 11:49 pm

      Hi Gary,

      I just tested this locally and entries in the trash were not counted towards the number of entries left. To be clear, are you saying the form itself wasn’t being limited or that the shortcode provided via this snippet was not working?

    1. David Smith
      David Smith Staff November 9, 2012 at 7:14 pm

      The counter is based on the number of submitted entries. To reset the counter you would need to delete the current entries. You can do this quickly from the Forms page by checking the checkbox of the form for which you like to delete the entries and then select the “Delete Entries” bulk action: http://grab.by/hpYM

  34. H.Kim
    H.Kim November 9, 2012 at 5:22 am

    Not working. Same problem as Allan reported.

    Copied the snipplet to the functions.php, used the shortcode. Result: Empty space.

    Reply
  35. Allan Schmidt
    Allan Schmidt September 25, 2012 at 5:14 pm

    For some reason, the shortcode doesn’t show any number, text or anything. Just empty space?

    Should I change anything in the code I copy/paste into functions.php?

    Reply
    1. David Smith
      David Smith Staff September 25, 2012 at 9:03 pm

      Hi Allan, it should be good to go. You’ll want to make sure you have an entry limit specified in your advanced form settings and that you’re referencing the correct form ID in the shortcode itself.

Leave a Reply

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

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

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

Download Snippet

Shortcode: Display Number of Entries Left

This field is for validation purposes and should be left unchanged.