Create a "Petition" style form

Hi Gravity Form Community,
I’m working on a project where we want our visitors to sign a Pledge on our Website. (Like a petition). But in order to encourage people to sign the form, we want to have two things that we don’t know how to do:

  1. A counter that display the total number of entry of the form (but we want to be able to enter manual numbers to control the total number of entries)
  2. We want to display on the website
    “Jane S. - Los Angeles - Pledged 30 seconds ago”
    “Patrick P. - San Diego - Pledged 30 seconds ago”
    like on this picture :
    pledge_example
    Is there a way to do this with ad ons ?
    Thanks!
    Tim

Off the top of my head, I think you can do this without an add-on.

  1. Total number of form entries
    Using the “pre_render” hook, you can call the number of form entries using the GFAPI like so (from https://docs.gravityforms.com/api-functions/#count-entries):

    $result = GFAPI::count_entries( $form_ids, $search_criteria );

and then display it at the beginning. If you want to be able to add a manual counter, create a shortcode that uses the same code above but add a “minimum” as an attribute (I’m assuming you want to show that there are a certain number of pledges before showing the exact number).

  1. List of entries with timestamp:
    This is similar to #1. Create a shortcode that displays the last X entries using this code (from #get-entries):

    get_entries( $form_ids, $search_criteria = array(), $sorting = null, $paging = null, $total_count = null ) {}

To get the datetime stamp as a “pledged 30 seconds ago”, you’ll need some “timeago” functionality, e.g. https://www.webslesson.info/2016/03/facebook-style-time-ago-function-using-php.html .

The city (e.g. “Los Angeles”) probably comes from your form.

Hi Timothy. There is this free solution to display the number of entries, via a shortcode:

For the social proof (“Patrick P. - San Diego - Pledged 30 seconds ago”) you could use this:
https://www.gravityproof.co/

Wow cool!

Thank you so much. It looks like exactly what we need. I will look in details into all the options.

Thanks for the quick answer!

Tim

1 Like
© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.