Skip to content

Instantly share code, notes, and snippets.

@chrisegg
Last active December 5, 2022 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisegg/26f55402dc493fcfdbe4adb94966d010 to your computer and use it in GitHub Desktop.
Save chrisegg/26f55402dc493fcfdbe4adb94966d010 to your computer and use it in GitHub Desktop.
<?php
//Copy everything below this line
/**
* GravityRanger Change Submit Button Text
*
* Allows you to change the submit button text after the button is clicked.
* https://gravityranger.com/change-gravity-forms-submit-button-text-after-submission/
*
* @instructions:
*
* 1. Change the $onclick value to whatever you'd like, currently set to "Sending, standby..." (end of line 28)
* 2. Add this code snippet to your functions.php file or a functionality plugin like WPCodeBox
* 3. This snippet applies to all forms, to target a specific form append the form id to the hook i.e gform_submit_button_ID
*
* @version 0.1
* @author Samuel Aguilera (Gravity Forms Support Engineer)
* @license GPL-2.0+
* @link http://gravityranger.com/
* @credits Gravity Forms Doc https://docs.gravityforms.com/gform_submit_button/
*
*
*/
add_filter( 'gform_submit_button', 'gr_change_submit_button_text', 10, 2 );
function gr_change_submit_button_text( $button, $form ) {
$dom = new DOMDocument(); $dom->loadHTML( '<?xml encoding="utf-8" ?>' . $button );
$input = $dom->getElementsByTagName( 'input' )->item(0); $onclick = $input->getAttribute( 'onclick' ); $onclick .= " this.value='Sending, standby...';";
$input->setAttribute( 'onclick', $onclick );
return $dom->saveHtml( $input );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment