Gravity Forms Duplicate Previous Entries

A client of mine needed his users to fill out the same form every single day, sometimes several a day, with mostly the same information. So I devised a snippet that allows you to select a date and copy all of the information from the entry (or entries) filled out on that date by that user to the new form. This is useful for forms where you only need to change the data in a field or two between submissions.

This solution is only meant to work with logged on users. The date selector form only returns entries submitted by the logged on user
This snippet works with my Continue Partial Entries plugin. Also, my previous version of this plugin was absolute crap. It’s waaaay better now



Create Date Selector Form

  • Create a new form and add a single Date field and make it required

Set Form CSS (optional)

  • Add the gf_simple_horizontal class to the form settings to make it a nice clean single line form like the demo above

Disable Notifications and Submissions (optional)

You may have different needs, but I definitely did not want a notification for every time someone used the date picker. I would recommend turning off all notifications for the form. Similarly, I also did want any entries created for the date selector form. I highly recommend Gravity Wiz’s plugin GP Disable Entry Creation to accomplish this.

Install this Snippet

Add the following code to your functions.php
The code does the following:

  • Replaces the default value of your date selector to the date of the most recent entry
  • Replaces the confirmation with a list of entries submitted on that date (simply redirects if there’s only one entry)
  • Loads the previous entry data onto the new form

Configuration Options

At the bottom of the code, under Configuration, you need to set the options for your form. You can copy the Configuration section to use for as many forms as you’d like.

  • form_id(int)(required)

    Specify the form by id for the form that you wish to copy

  • form_url(string)(required)

    Specify the url of the form you wish to copy

  • date_form_id(int)(required)

    Specify the form by id for the date selector form

  • date_form_field(int)(optional)

    Specify the field id of the date field on the date selector form. Defaults to 1

  • exclude_field_id(string)(optional)

    Specify the fields by id separated by spaces for any fields you wish to exclude from copying. Example: 'exclude_field_id' => '3 6 19 25'

  • exclude_type(string)(optional)

    Specify any field types separated by spaces for types you wish to exclude from copying. Example: 'exclude_type' => 'signature hidden date time'

  • custom_confirmation(string)(optional)

    Specify the confirmation message that appears if there are no entries that match the specified date. Defaults to 'There is no entry for this date'

Comments 3

  1. Thanks so much for this Ryan! I have a very complicated form that people fill out regularly.
    FYI, if more than one form was submitted on a date, the time it was submitted was of no help, so I edited it to show a field from the form instead. Works great!

    $event = $single[4];
    $confirmation .= ‘Event: ‘ . $event . ‘‘;

Leave a Reply

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