Skip to content

Instantly share code, notes, and snippets.

@rxnlabs
Last active July 7, 2022 12:29
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rxnlabs/9554149 to your computer and use it in GitHub Desktop.
Save rxnlabs/9554149 to your computer and use it in GitHub Desktop.
WordPress - Save and submit a multistep form using Gravity Forms. Multistep forms don't allow you to submit the form if the user decides to leave before completing the form. This allows the user to submit the form at any step.
//clone the form submit button for the form
var save_btn = jQuery('#gform_submit_button_2').clone();
//change the label of the midway submit button
save_btn.val('Save and Submit');
//get the ID of the gravity form
var gravity_form = jQuery('#gform_submit_button_2').closest('form');
var gravity_form_id = gravity_form.attr('id');
gravity_form_id = gravity_form_id.split("_");
gravity_form_id = gravity_form_id[1];
//get the last page of the form
var last_page = gravity_form.find('div.gform_page:last');
//check if the last page of the multistep form is visible. If NOT, show the submit button
if( last_page.css('display') === 'none' ){
jQuery('div.gform_page_footer').append('<span class="gform_multistep_append">OR</span> ');
jQuery('div.gform_page_footer').append(save_btn);
//change the necessary hidden form elements needed to submit the form
jQuery('input#gform_target_page_number_'+gravity_form_id).val('0');
}
@yogesh5491
Copy link

Hey, I have just started working on wordpress and gravity forms. I have made a multistep form with Gravity forms and linked it with mailchimp. Now I want the form to send data to mail chimp on each step, rather than only on the final step.

I have a very basic question. Where do I add this in wordpress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment