Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set up a Gravity Form (in this case, form ID 1) to be sent from one user to another, by repurposing the "save and continue" button.
<?php
add_filter( 'gform_savecontinue_link_1', 'prefix_savecontinue_form_id_1', 10, 2 );
/**
* Maybe remove the "save and continue" button from Gravity Form ID 1.
* Checks to see if the "save and continue" token is present--
* if no, the button will render, otherwise not.
*
* @param string $save_button
* @param object $form
* @return string
*/
function prefix_savecontinue_form_id_1( $save_button, $form ) {
if ( prefix_does_token_exist() ) {
return '';
}
return $save_button;
}
add_filter( 'gform_submit_button_1', 'prefix_submit_form_id_1', 10, 2 );
/**
* Maybe remove the "submit" button from Gravity Form ID 1.
* Checks to see if the "save and continue" token is present--
* if yes, the submit button will render, otherwise not.
*
* @param string $button
* @param object $form
* @return string
*/
function prefix_submit_form_id_1( $button, $form ) {
if ( ! prefix_does_token_exist() ) {
return '';
}
return $button;
}
/**
* Check to see if the second user is viewing the form (based on whether the Gravity Forms token is present).
*
* @return boolean
*/
function prefix_does_token_exist() {
return (bool) filter_input( INPUT_GET, 'gf_token', FILTER_SANITIZE_STRING );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.