Shortcode: Display Number of Entries Submitted

Extends the [gravityforms] shortcode, providing a custom action to retrieve the total entry count for a given form. Also supports retrieving entry counts by entry status (i.e. “trash”, “spam”, “unread”, “starred”).

Are you limiting how many entries can be submitted and looking for a way to display the number of entries left? We’ve got a shortcode for that too!

After installing this snippet, you will be able to display the number of form entries that have been submitted with the following shortcode:

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

Getting Started

  1. Check requirements

  2. Install the snippet

    • Copy and paste the entire snippet into your theme’s functions.php file.
  3. Configure the shortcode

    • For the basic version just enter your form id and the shortcode will return the total number of submitted entries!
    • If you would like to have a little more control over the type of entry being pulled, read on for some additional configuration options.
    • View available shortcode attributes

Usage Examples

Basic Usage

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

[gravityforms action="entry_count" id="2"]

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


Unread Entries, Comma Format

[gravityforms action="entry_count" id="2" status="unread" format="comma"]

Display the entry count for unread entries using comma format (i.e. “1,001”).


Trashed Entries, Decimal Format

[gravityforms action="entry_count" id="2" status="trash" format="decimal"]

Display entry count for entries in the trash using decimal format (i.e. “1.001”)


Shortcode Attributes

  • id (int) (required)

    The ID of your form. Defaults to false.

  • status (string) (optional)

    The entry status type that you would like to display number of entries submitted for. Defaults to “total.” Options include: “total”, “unread”, “starred”, “trash”, and “spam”.

  • format (string) (optional)

    The type of formatting to be used when displaying the entry count. Defaults to false. Options include: “comma” and “decimal”.

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!

Learn more about Gravity Forms Shortcodes

Our Complete Guide to Gravity Forms Shortcodes will show you each type of shortcode available for Gravity Forms, how to set them up, as well as how to fine tune parameters to customize which form data is displayed on your pages.

Comments

  1. PWIA Webmaster
    PWIA Webmaster January 6, 2023 at 5:51 pm

    Is there a way to count how far “down” an entry is. For example, building a waitlist, I want to know what position a entry is, are they 10th in line, 20th in line. I was thinking I could get the entryID of the first one and then subtract the the differences of everything. However, entryIDs are not in order. Meaning if I create another entry in another form and then add a new one to this form, it is not sequential. Plus if you use random entryIDs, then it all goes out the door.

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff January 9, 2023 at 2:58 am

      Hi,

      You can use our GP Unique ID Perk to generate sequential IDs that will be specific to the entries of a form. This should work better for what you’re trying to do.

      Best,

    1. Dario Space
      Dario Space Staff December 10, 2021 at 10:33 am

      Hi Paolo,

      This snippet counts how many entries were submitted. If you need to tweak the snippet you can get in touch with us via our support form if you have an active Gravity Perks license so we can take a closer look at your setup.

      Best,

    1. Dario Space
      Dario Space Staff September 21, 2021 at 7:45 am

      Hi Dean,

      Thanks for sharing with the community. We already followed up on this via email, but I wanted to post this in the comment thread so other customers could see it.

      Cheers,

  2. Steven Grimmer
    Steven Grimmer July 9, 2021 at 7:25 am

    Hi there

    Nice bit of code. I am showing the number of entries of the form – all good. But I also want to add a number to this every so often that reflects offline forms that are physically collected. Is there a way to do this?

    Reply
    1. Scott Ryer
      Scott Ryer Staff July 9, 2021 at 11:04 am

      Hi Steven,

      We don’t have a ready solution for this one. If you don’t collect many offline, you could enter the physical form data into the Gravity Form.

    1. Scott Ryer
      Scott Ryer Staff October 12, 2020 at 5:05 pm

      Hi Mareks,

      This isn’t currently supported. If you are a Gravity Perks customer with an Advanced or Pro license, drop us a line and we can look into adding support for this.

  3. Rob
    Rob July 23, 2018 at 2:30 pm

    Hello,

    When I try to run this shortcode via do_shortcode, I get an error.

    Here’s the PHP I’m using:

    echo do_shortcode(“[gravityforms action="entry_count" id="1" format="comma"]“) . ‘ people have taken the pledge to…’;

    I’ve tried to escape the quotes inside the do_shortcode function, but when i do that the shortcode isn’t even recognized.

    Here’s the error I’m getting:

    Parse error: syntax error, unexpected ‘entry_count’ (T_STRING), expecting ‘,’ or ‘)’ in pledgetally.php on line 3

    Reply
    1. David Smith
      David Smith Staff July 24, 2018 at 10:58 am

      You’ll need to use single quotes to wrap the shortcode.

      '[gravityforms action="entry_count" id="1" format="comma"]'

    2. Rob Monti
      Rob Monti July 24, 2018 at 3:06 pm

      I actually tried that. When I did that the error said that do_shortcode was an unrecognized function.

  4. Rochel
    Rochel July 13, 2018 at 7:55 pm

    I’m currently using this shortcode but I’m wondering how to tweak it so it can display the number of entries from multiple forms. How can I add multiple for ids?

    Reply
    1. Joeri
      Joeri November 17, 2020 at 7:15 am

      I would also like to know if this is possible… I am having a case where I need to show the total number of entries from multiple forms that are related to each other.

    2. Samuel Bassah
      Samuel Bassah Staff November 17, 2020 at 9:13 am

      Hi Joeri,

      This isn’t currently supported. If you are a Gravity Perks customer with an Advanced or Pro license, drop us a line and we can look into adding support for this.

      Best,

  5. Adam
    Adam March 5, 2017 at 8:59 am

    This looks great, Is there anyway to display entries sent to a certain author email ? I currently use the below code to email the author of a particular page when a form entry is made.

    What id like to do is create a page where that author can then see the entries which has been submitted to him, your code seems to do that, but obviously it would display ALL entries for that form, could someone help with what code id need to use narrow it down only authors saw their own entries from the same form.

    Reply
    1. Alex
      Alex February 3, 2017 at 11:37 pm

      Today I modified this shortcode and it works as [donations form=9 start_date=”2017-02-01″ end_date=”2017-02-03″] But I don’t know how to make input on HTML page:

  6. Joe
    Joe November 15, 2016 at 3:06 pm

    Hi again David. You were so helpful earlier I thought I’d pose another question! Is there a way to show a counter for form submissions to the same form ID, but where the form is used on different URLs (this is a job board, I’d like to display the total amount of submissions per job).

    Reply
  7. Berke
    Berke August 1, 2016 at 11:43 am

    Hello,

    I want to add 45(or 35,75,200) as a fixed value to add on number of the resulting. For example entries total = 20. I want to add 45. result=65. I want to show 65.

    $x = [gravityforms action="entry_count" id="1"] ; $result= $x + 45; echo $result;

    My Php knowledge is very poor. I wrote something like this but it does not work. $x hasn’t a value.how can I do it?

    Reply
  8. Cam
    Cam May 3, 2016 at 6:05 pm

    Thanks for the code, it works great! I would like to know how I could set a base number for it to start counting submissions from?

    Reply
    1. Cam
      Cam May 3, 2016 at 10:03 pm

      I have an old form that had 300 submissions, then I deleted the form and I just rebuilt it so the submissions is currently sitting at 5 instead of 305. What I would like to know is can I input a starting number in the code eg 300 submissions and then it adds to this so right now my code would output 305 submissions. Then if I get another submission it goes to 306, 307 etc. Hope that makes sense :)

  9. Farting Santa
    Farting Santa April 18, 2016 at 8:09 am

    Is there a know way to get the count of a form based on the page the form was submitted on. Racking my noodle on how to do this, I’m trying to echo how many people have submitted the form based on the page url as the same form is pulled through via the template for each page if that makes sense.

    Reply
    1. David Smith
      David Smith Staff April 18, 2016 at 8:53 am

      It is possible but not with this simplistic function. It would require a custom query to the DB. If you’d like to hire us to write such a query, we’d be happy to help. Get in touch.

    2. Farting Santa
      Farting Santa April 18, 2016 at 9:10 am

      Ahh no problem David, I thought there may of been a simple way of checking if an entry contained a value, never mind.

  10. Adriana
    Adriana April 6, 2016 at 3:19 pm

    Great snippet! Using it for “total contributors” count. I’d also like to use it for “Total $ paid”. Each entry is a payment, so I’d like to display how much money we have raised so far. Let me know if that is possible.

    Reply
    1. Jordan Smith
      Jordan Smith April 7, 2016 at 2:43 am

      Hi Adriana,

      I built a recent site that needed something very similar to what you are describing. The only difference is I was displaying total miles logged.

      In order to display the total amount raised, you’d need to add the values from each form entry.

      This snippet will allow you to retrieve the total value of a specific form field for all entries. I also added some additional instructions to help you use the value where needed.

      https://gist.github.com/hirejordansmith/348e6d32d3a1ed75bcb4e27f2bc8acb3

    2. Adriana Ross
      Adriana Ross April 7, 2016 at 8:43 pm

      Ok that pretty genius, no lie. hmm… What about if you have 2 fields?

      customer gets asked “are you individual or company?”

      Individual has to pick their contribution of $5, 10, 20 or 30 from field id 3.

      Company has to pick their contribution of $20, 40, 80 or 100 from field id 4.

      I still want to show total raised in one display [total sum]

      Thoughts?

    3. Jordan Smith
      Jordan Smith April 8, 2016 at 9:29 am

      Hi Adriana,

      You can collect as many field totals as you want and assign to a variable then just add the totals together in a “total_sum” variable.

      I’ve updated the gist in my first link to show how this is done. Enjoy!

  11. Axel
    Axel February 14, 2016 at 6:56 am

    HI David, From now I can view the counter above or below the form Can I use this number within the module or store it in some way?

    Thanks in advance

    Reply
  12. Adriana
    Adriana January 31, 2016 at 6:12 pm

    Does not seem to work with newest WordPress version. All I did was paste to bottom of functions.php. Removed php tag and save. It saved ok, but when I checked to see if website was working it took too long and gave timed out error.

    Reply
  13. Kathy
    Kathy November 27, 2015 at 1:51 pm

    The counter isn’t working for me at all. I have a few classes on the above page that have one entry in them but I can’t get the counter to show up. (I did them myself.)

    Thank you.

    Reply
    1. Kathy
      Kathy December 2, 2015 at 10:21 am

      Thanks for fixing the functions.php file. Who knew one curly brace could throw everything off? Thanks for the catch! All is working beautifully now. Thanks for the help!

  14. Schalk
    Schalk October 16, 2015 at 1:39 am

    Hi,

    I am showing the total count of a specific field in all entries with the snippet below, but tried to modify it with some code from your snippet, in order to show only include starred entries; Can you possible shed some light, please:

    `function gravitywp_count_func ( $atts, $content = null ) { extract( shortcode_atts( array( ‘formid’ => ‘formid’, ‘field’ => ‘field’ ), $atts ) );

    $search_criteria = null;
    $sorting = null;
    $paging = array( 'offset' => 0, 'page_size' => 200 );
    $entries = GFAPI::get_entries($formid, $search_criteria, $sorting, $paging);
    $countentries = GFAPI::count_entries( $formid );
    $gwp_count = 0;
    for ($row = 0; $row < $countentries ; $row++) {
        $gwp_count += $entries[$row][$field];
    

    } return $gwp_count; }

    add_shortcode( ‘gravitywp_count’, ‘gravitywp_count_func’ );

    ?> `

    Reply
    1. Schalk
      Schalk October 16, 2015 at 5:06 am

      Hi, Further to my earlier comment ( not yet approved ), I have managed!

      I changed $search_criteria = null; to $search_criteria[‘field_filters’][] = array( ‘key’ => ‘is_starred’, value => true );

      and then simple change the status to STARRED for entries to be included.

      Thank you,

  15. Prati
    Prati September 13, 2015 at 7:30 am

    Hi David,

    Thanks for this very useful snippet.

    Is it possible to display entries count by parameter value. I have one form that serves multiple purposes. Say booking an event, sending an invite, scheduling an event, requesting a quote.

    Can I display no. of times an event has been booked by using your shortcode like, [gravityforms action="entry_count" id="my_form_id" field_values='event_action=book this event']

    Or display number of event invites sent out by using [gravityforms action="entry_count" id="my_form_id" field_values='event_action=invite a friend']

    Hope you will help me achieve this.

    Many Thanks.

    Reply
  16. Hugo
    Hugo June 18, 2015 at 4:21 am

    Hi David,

    Do you think it might be possible to make each form act independently when counting the number of entries. For example if i have put the same form on multiple posts but want to count the number of entries independently.

    I would hugely appreciate the help! Also if you think it is possible could you point me in the way of a developer who could help implement this.

    Thanks,

    Hugo

    Reply
    1. David Smith
      David Smith Staff June 18, 2015 at 6:51 pm

      I’ve written some code that does something similar here. You could pull the “is_limit_reached()” function out of the class and strip it down so that it simply returns the entry count. I’ve highlighted the line where it fetches the entry count by embed URL here.

    1. Sammy
      Sammy March 30, 2015 at 4:43 pm

      Yes I have. My form ID is 1. So I put [gravityforms action="entry_count" id="1"]

      See page I have on Website field. That’s the form, there are 3 entries in form but there’s a 0 showing there.

      Regards,

    2. Sammy
      Sammy April 7, 2015 at 5:07 pm

      Hi there.

      How do I register on this site to get support? I need this snippet to work on my site.

      Regards

  17. Sergio
    Sergio March 25, 2015 at 12:51 pm

    Hi David,

    great snippet! Can you give more information about hiring you to modify it to show only the number of entries of logged user?

    Thank you in advance,

    Sergio

    Reply
  18. Robby Payne
    Robby Payne February 18, 2015 at 12:37 pm

    Wow! This is fantastic!!! Is there any way to use this but have it pull only the number of entries with the author_name of the particular post?

    I have a single form that is pulling the reply email from the author_name and then sends the notification with that field dynamically populated. However, it’s still the same form id across all the posts. So, for instance, if I have 20 posts with 5 authors and each one gets a single form entry, the counter I have in place (that works terrifically already, BTW) would show 20 entries on every one of those posts.

    If I need to communicate in a different way with you all, let me know. Thanks for your help!!!

    Reply
    1. David Smith
      David Smith Staff February 19, 2015 at 8:14 am

      Hi Robby, this shortcode is limited in that it uses a very simple Gravity Forms function that gets the total count for each form without the ability to filter by entry values. You could write something custom using the GFAPI::get_entries() method to fetch the desired entries and then use PHP’s count() function to get the number of entries retrieved.

  19. Andrew Blackburn
    Andrew Blackburn December 11, 2014 at 10:48 am

    I’m curious if it would be possible to add constraints to this snippet? Specifically, I am looking for a way to display the number of entries by the user that is signed in. I’d like to display this at the top of my form (log-in is required): “This is the Nth time you have signed in”.

    Reply
  20. Chris McCoy
    Chris McCoy December 3, 2014 at 9:58 am

    would be cool if this could work with the limit submissions per ip, say if you allow 3 per 24 hours, it shows the amount left the user could submit

    Reply
  21. Adam
    Adam November 7, 2014 at 10:06 am

    Great snippet…THANK YOU. FYI you need not add the call to PHP on the first line, that will give you the white screen of death.

    thanks again

    Reply

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 Submitted

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