Auto-Submit a Form on Page Load Gravity Forms

Feb 14, 2022

2 Min. Read

Share URL

This page may contain affiliate links. Please read my disclaimer for more information.

We have had a couple of requests from Gravity Forms users that wanted to know how to submit a form automatically once the form page loads.

In some cases, they are passing data via a query string and all they need is for that data to populate the form and be submitted.

Use Case Example

One use case I can think of is a simple solution for employees to clock in and out. They log in to their account, and click the “clock in” button which is preloaded with a URL and any necessary parameters. I’ve demonstrated this below.

To get this to work you only need an HTML field in your form and the code snippet below.

Setting Up Your Form

You can add whatever fields you’d like to your form, but for this to work, you must have an HTML field with the code below added to the content field.

Below is the code snippet you will need.

To make the code work you will need to make two modifications after pasting it into your HTML field.

  1. Change ID# on line 24 to your forms actual ID number
  2. Change the delay time on line 27, currently set to 500 which is half a second
https://gist.github.com/chrisegg/0bf6d0362f57bebe0539d8ef565cde1b

Additional Code Snippet

If you prefer to not have a delay in your submission and instead have the form submitted as soon as the form renders, you could use the snippet below.

Just be sure to replace ID# with your forms ID number.

<script type="text/javascript">
     jQuery(document).on('gform_post_render', function(){
           jQuery('.gform_wrapper:not(.gform_validation_error) form#gform_ID#').trigger('submit');
    });
</script>

The Wrap Up

I’m sure there are many other use cases where having the ability to auto-submit a Gravity Forms form is necessary, and if you have one of those cases, hopefully, this solution will work for you!

If you have any questions or need additional assistance, please use the comments below.

Photo of author
About the Author
Chris Eggleston
Husband. Father of 4. Grandpa of 2. Chief Problem Solver exploring business systems, technology, AI & faith — helping people solve real problems. @mantiswp @chrisegg

Support Chris - Donate $5

Gravity Wiz Add-Ons

Advertisement

0 0 votes
Article Rating
Subscribe
Notify of
guest
16 Comments
Inline Feedbacks
View all comments
Doug H
Doug H
7 months ago

Hello, I’m wondering if you are still able to offer any assistance on the auto-submit code. I was not able to make either one work. Both sets of code were set up as instructed but the form did not auto submit in either case. I was able to manually submit in each case. Are there any adjustments for new versions of Gravity that might need to be made?

Doug H
Doug H
Reply to  Chris Eggleston
7 months ago

Thank you for the reply… I’m not sure why it wasn’t working for me at first but I got it going after matching the code exactly to the snippet. It works perfectly. Thank you!

samy
samy
1 year ago

This information is fantastic!

Sepehr
Sepehr
2 years ago

Thanks. It really saved me

Russell
3 years ago

This didn’t work for me for some reason

Russell
Reply to  Chris Eggleston
3 years ago

Hi,

Yeah I tried both and amended the form id. I have some required fields on my form but i expected just to see the rejection message to say the required fields haven;t been completed (as if i had manually clicked the submit)

Norman
Norman
3 years ago

Frickin’ cool!!

My only comment is clarification on the syntax regarding the form ID. Here’s my working code:

Norman
Norman
Reply to  Chris Eggleston
3 years ago

I thought I put it in there — I just replied to my post with the code (again?). In any case, I used the “additional code snippet” from above and used the substitution below. Per the directions above, I literally substituted the characters “ID#” with my form number “10”, resulting in the look below.(Perhaps it was just me, but it wasn’t exactly obvious to me what exactly should be replaced.)

This really is frickin’ cool! Thanks, Chris!

BTW, I’m considering removing the confirmation webpage notification once the form is automatically submitted — I can’t find how to disable or delete the confirmation. Any ideas?

‘form#gform_10’

Norman
Norman
Reply to  Norman
3 years ago

OK, the code doesn’t show when I copy/pasted, please delete this post and edit my original to show my example above if you don’t mind.

Marky
Marky
3 years ago

Thank you for info.

by the way, how to put conditional logic?

For Example, submit button is not shown based on the conditional logic then pause or stop auto-submit.

is there an example can see and try?

Related Post

How to Secure a Digital Broadcast Page with Gravity Forms Submit to Access Add-On

Live events and webinars are powerful ways to connect with your audience, but hosting them directly on your WordPress site...

Oct 3, 2025

4 min. read

Step-by-Step Guide: Sending a Gravity Forms Notification to the User

Gravity Forms notification feature allows you to send emails to users automatically when they submit a form. This is useful...

Mar 20, 2025

5 min. read

Gravity Forms Multi-Date Picker

Gravity Forms is a powerful form builder, but you might occasionally find some limitations. For example, the date picker field...

Nov 13, 2024

4 min. read

How to Migrate From WS Forms to Gravity Forms: A Step-by-Step Guide

Migrating from WS Forms to Gravity Forms can seem daunting, but with the right approach, it can be a smooth...

Oct 26, 2024

4 min. read

How to Connect Gravity Forms to SendFox: A Step-by-Step Tutorial

This tutorial will walk you through connecting Gravity Forms to SendFox and ensuring your contacts are added to your email marketing...

Oct 16, 2024

5 min. read

How to: Gravity Forms BMI Calculator

Many people don’t realize that the calculation feature is built into the Gravity Forms core plugin and is available for...

Oct 10, 2024

4 min. read