Description
This filter can be used to dynamically change the confirmation message or redirect URL for a form
Usage
<?php
add_action("gform_confirmation", "custom_confirmation", 10, 4);
?>
You can also specify this per form by adding the form id after the hook name.
<?php
add_action("gform_confirmation_6", "custom_confirmation", 10, 4);
?>
Parameters
$confirmation
- (string|array) The confirmation message/array to be filtered. For a simple confirmation message, set this variable to the message you would like displayed in the screen. To redirect the page to an URL, set this variable to an array in the following format:
<?php
$confirmation = array("redirect" => "http://www.google.com");
?>
$form
- (Form Object) Current form.
$lead
- (array) Current Entry array
$is_ajax
- (bool) Specifies if this is configured to be submitted via AJAX
Examples
This example dynamically changes the confirmation message for form 102 and set form 101 to redirect to www.google.com
<?php
add_action("gform_confirmation", "custom_confirmation", 10, 4);
function custom_confirmation($confirmation, $form, $lead, $ajax){
if($form["id"] == "101"){
$confirmation = array("redirect" =>"http://www.google.com");
}
else if($form["id"] == "102"){
$confirmation = "Thanks for contacting us. We will get in touch with you soon";
}
return $confirmation;
}
?>
Source Code
This filter is located in form_display.php