Gravity Forms

When creating a form, it's nice to redirect the user the back to the same page with a custom thank you a message.

The example below will accept FORM ID: 3 and will send the user back to the $embed_url when the user submits the form.

Then on the thank you page you can use the shortcode to display a message at the top of the page.

All you need to make sure is that on the form, you have a hidden field called "Embed URL" and you store the embed URL and make a note of the entry id.

#####################################
//redirect the user when they fill in a property details page form
//added by craig@jucra.com on 25/2/2020
#####################################
add_action("gform_after_submission_3", "redirect_user_form_id_3", 10, 2);
function redirect_user_form_id_3($entry, $form){
	
	//set the thank you page parameters for redirect
	$embed_url = $entry['9'];
	
	//redirect the user to thank you page
	header("Location: " . $embed_url . "?msg=thanks");
	exit; 
	
}

#####################################
//custom thank you message short code
//by craig@123marbella.com on 13th Jan 2015
#####################################
add_shortcode( 'thanks_message_form_3', 'thanks_message_form_3' );
function thanks_message_form_3( $atts, $content = null ) {
    
    if($_GET["msg"] == "thanks") {
    
        $html = "<div style='background:green;padding:20px;color:white;margin-bottom:45px;'>";
        $html .= "<strong>Thank you for your request for the buyers guide.</strong>";
        $html .= "<br><br>";
        $html .= "Please check your email.";
        $html .= "<br><br>";
        $html .= "It should arrive within a few minutes, if not, please either check your spam folder or whitelist our domain.";
        $html .= "<br><br>";
        $html .= "If you have a spam filter, please whitelist our domain: suncoasterestates.com";
        $html .= "</div>";
        
        return $html;
    
    }
    
}
  • 2 Users Found This Useful
Was this answer helpful?