PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Adding a form entry counter on the front end, by the form

  1. RichardBest
    Member

    Hi All - I'm not sure whether anyone has asked this one before. Couldn't find it when I had a look.

    Would it be possible do you think to add a form entry counter on the page that contains a form? As we know, GF creates distinct entry IDs per form, it seems in pure sequential order. I'm wondering if we somehow use that feature to note, on the page containing the form, how many entries have been submitted through it. That'd be really helpful for situations where we set up forms to close down after X number of entries.

    Many thanks for any help.

    Richard

    Posted 13 years ago on Monday December 20, 2010 | Permalink
  2. Here is a post that discusses how to display an entry count, and includes a code snippet:

    http://forum.gravityhelp.com/topic/display-entries-count-on-site

    The code you would need to use looks like this:

    <?php
    $summary = RGFormsModel::get_form_counts(2);
    echo "The Form count for Form #2 is: ".$summary['total'].".";
    ?>
    Posted 13 years ago on Monday December 20, 2010 | Permalink
  3. RichardBest
    Member

    Awesome. Thanks very much Carl.

    Posted 13 years ago on Monday December 20, 2010 | Permalink
  4. RichardBest
    Member

    Hi again. I've just checked this out. It works perfectly, thanks. I'm using it in conjunction with a plugin that enables one to execute PHP in a page or post via a defined shortcode. This is great as it enables execution without having to add any php to your templates.

    I have one further question on this if I may please. Is it possible to run a php command that displays a message once a certain form count number is reached? For example, if I set up a form to allow only 15 submissions/entries, could I run a php command for that form which displays a message, like "Only 5 chances left!", when 10 submissions/entries have been submitted?

    Many thanks in advance.

    Richard

    Posted 13 years ago on Tuesday December 21, 2010 | Permalink
  5. Well you'd have to write the custom PHP to do so. You'd get the form count for the form and then use PHP to subtract whatever the predefined total is and then display how many chances are left with a message. So yes, using the code above you could modify it to display a message like "Only 5 chances left!".

    Posted 13 years ago on Tuesday December 21, 2010 | Permalink
  6. This is great! Thanks for the tip. Now my question: is there a way I can show the total entries count of MULTIPLE forms with some type of variation on this? I have one form duplicated for various landing pages, but want the total count of all entries to display.

    Thanks in advance!

    Posted 13 years ago on Wednesday January 19, 2011 | Permalink
  7. Never mind. I just used array_sum to combine the multiple form entry totals. Unless, of course, you know a better way that's built into Gravity Forms?

    Posted 13 years ago on Wednesday January 19, 2011 | Permalink
  8. Nope, that'll do the trick. :)

    Posted 13 years ago on Thursday January 20, 2011 | Permalink