Add a button which submits form contents to a custom function

Hi guys

I have my form with a submit button. When the user clicks submit the form redirects to another page. This all works great.

I want another button next to the submit button saying “Email me”. When clicked it should email the form’s contents (along with some other content) and redirect the user to a Thanks page.

Its not a simple case of calling a function from the custom button, becuase the function script needs all the information from the form. How can I achieve this? I cant have to submit button can I?


You can’t have two submit buttons, no. Why not set up a notification that sends all the data to you when the form is submitted? You can change the submit button text from the default “Submit” to “Email me” and then when they submit the form, an email notification can be sent to you. Is that what you’re looking for or do you need to do something else?

Thanks Chris. Thats a good idea. But the existing ‘Submit’ button needs to redirect the user off to a payment gateway together with some values from the form.

To clarify: I want 2 buttons on my form: Buy Now and Email Me. Buy Now should redirect user to payment gateway together with some field values. Email Me should email the form’s contents to the user.

So - basically - I need to have 2 buttons which passes the values of the form to perform 2 different actions. Does that make sense?

There’s no functionality in Gravity Forms to do that. You could add an HTML field with an additional button in it that does the “Email me” part. You would have to customize how that works yourself, because you would not be using Gravity Forms functionality at all.

Thanks Chris - I understand.
Ive just thought: I could have a question “Would you like to buy this now or have your data emailed to you”. This then displays the relevant button. (So - in effect - there would be 1 submit button).
Could I ask how I would could detect which code to execute depending on what option was selected? Would you have a ‘GF on submit’ function which has an if/else in it to either redirect user to payment gateway or email form content to them depending on what theyd selected?

You could have a checkbox that says “Email me” (or any more explanatory text you want) as the last field on the form, then set up a conditional confirmation (redirect to page) and conditional notification (email the contents) to use if the checkbox is selected.

You could alternatively use two radio buttons (two in a set) to specify what should happen when the Submit button is clicked, and setup the conditional confirmations and notifications accordingly.


Wow. Works like a charm. Thanks so much Phil!

However, the conditional Submit button display doesnt work. I dont want the Submit button to display until the user has selected either checkbox. (Ideally I want the button label to display different text depending on what the user has selected, but ust dealing with this issue first!).

Ive checked the conditional logic and settings and cant see anything obvious. :confused:

Hi Darryl

Sorry for the VERY late reply - I never saw the notification that you’d replied. Not sure if you’d managed yet in the meantime? In case you havent:

Changing the label on the submit button is not available as standard in Gravity Forms - you may have to use custom coding for that. However, conditionally hide/display the submit button is easy, but it’s found in the form settings.


I hope that helps!

Thanks so much Phil. I did try the Button Conditional logic but it wasnt working for some reason. Ill give it another go tonight.

1 Like

Having said that, there is a roundabout way that you could have two different “submit” buttons. To do that, you need to conditionally display/hide entire form pages - which means obviously that this would only work if you have a multi-page form.

You would then set the text on the “next” button of the second-to-last page as the one version of the text you want on the submit button, and the text on the actual submit button as the other version.

The form item (checkbox or radio button group) that would determine the conditional logic would, however, have to be before the second-to-last page for this to work. So then you would conditionally hide either the second-to-last page or the final page. If the final page is hidden, the “next” button on the second-to-last page will act as a submit button (I stand to be corrected, but that’s what I’ve experienced in the past).

You would obviously then still use conditional confirmations and notifications.

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