Have you filled out a lifetime of forms? Surely there are some things we can do to reduce Repetitive Form Entry Fatigue (no I will won’t call you Shirley).

While I have it used it super extensively, one of my favorite WordPress plugins Worth Paying for is Gravity Forms. Beyond all the features in packs in to the Dashboard interface, a world of possibility lurks below the hood via custom hooks and filters and stuff.

One of my web design clients runs an annual silent auction. In the past, their organization had people email in their bids, meaning my client was performing a raft of copy/paste to put the information in a spreadsheet. I suggested using Gravity Forms to streamline it. Their first pass was one giant form with like 100+ items; I convinced them to instead create one form that could be embedded into 100+ separate posts for each item.

While Gravity Forms provides among the data it stores for each response the URL of the page the form is embedded in, I knew it is more useful to store the actual name of the item, which in this case, is the title of the post.

To put this into motion, I added a field item to the form, and in the advanced tab, I check the Visibility Option to be hidden since the site visitor never needs to see it. But the important step here is to check the box for Allow field to be populated dynamically. This opens another setting where I can define a Parameter Name

Setting up a hidden field to be tracked by a parameter named “auction item”

By allowing it to be “populated dynamically” it means my script can set its value, and that value will be stored in a variable named auctionitem.

The code needed to do this is pretty easy via the Gravity Forms gform_field_value_$parameter_name filter.

For the site I am doing, the code is:

When the form is built, it will insert the title to the post into this hidden form, and thus the data goes along for the ride with the other stuff people fill on the form.

But I ran into a problem of my own making. When setting up the site I was pretty sure the sophistication of the theme we chose would cover all the needs of the client. So unlike my usual practice now, I did not create a child theme. The code I wrote above needs to go into the theme’s functions.php file, and I refuse to modify core theme files which would be lost in an update.

I put into play the Code Snippets plugin which gives me the end around I needed; I can add my custom code in the plugin’s interface, and it operates as if it is in the theme’s functions file (once their auction is done, I offered to move their site to a child theme, where it’s cleaner to add custom code).

The other thing I offered as to do with the above mentioned Form Fatigue. If one person decides to bid on multiple items, on each page they need to enter a name, address, phone, email. And while most browsers do okay with Auto filling forms, it seems more elegant to have those fields already filled out if they have been entered at least once.

This is a job for cookies:

I had done this before for a project where the gravity forms auto-filled an email address field. To set this up, the email field in your form needs to be enabled with Allow field to be populated dynamically (under the advanced tab). With great originality, the parameter name I choose is email.

The code I had used before was:

This “action” for gform_pre_submission_2 is performed before the Gravity form ID 2 is submitted. The script cycles through the form fields, and if the field is either the name field or the email field it saves the value to a cookie. the other functions work to populate the fields like the example above, except the value comes from a cookie.

So I set up the forms the same as above:

I modified all the scripts above to match these additional fields… and it did no save the data when the form was submitted.

That’s because the name field, split into 2 for first name and last’ and the address field, split into several more, doe snot work the same as a single field for a name or email.

Fortunately I found in the Gravity Forms help area a better, more generalized function, that also dealt with this kinds of compound fields:

This now works perfectly. Once you have filled out and submitted one form in the auction, on return to any auction form page, your info is magically entered for you (if your name, in this case, is Harry Cantrell that’s one of my test personalities).

Harry is happy because he does not have to keep typing in the same info on every auction bid page.

But here is why some web cookies are good. Because they are associated with the domain, if the client has other web forms, if they enable populated dynamically for a name, email, address,or phone field, as long as they use the same parameter names, these forms too are auto populated.

It’s a pretty small addition to the experience, and most may not notice it, but it’s sensible approach (I think) for form driven sites.

Don’t make a good person keep filling out the same form fields!

Featured Image: My words (not President Obama’s) superimposed on President Obama filling out his 2010 census form – West Wing Week episode 1 – Future Planes of the Future a Wikimedia Commons photo by The White House shared into the public domain as a US Government work. Have I said lately how much I miss a real Presidential President?

Profile Picture for Alan Levine aka CogDog
An early 90s builder of the web and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person.


  1. Re the title piece, I think you can also just do default value of {embed_post:post_title} and it’ll get you the site title.

    I’ve done a bit of setting of fields via javascript from various page/post values lately as well. It feels lighter weight but that could be my imagination.

    I like the cookie. I’ve never really done stuff with those before.

Leave a Reply

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