I need a quote form that will accept a drop down, and a zip code. Based on the dropdown it goes to a certain page within the site for more information. Is there a way to do this in gravity forms???
I need a quote form that will accept a drop down, and a zip code. Based on the dropdown it goes to a certain page within the site for more information. Is there a way to do this in gravity forms???
Hi, jseat,
Yes, this can be done. There is a Gravity Forms hook called "gform_confirmation" (http://www.gravityhelp.com/documentation/page/Gform_confirmation) that you can use to change the redirect URL. With this hook you can use the page you specified in the drop down as your new redirect URL. Below is an example where I check the values in my drop down and depending on what the user chose, I set what the redirect should be. There is a default condition in case they do not select anything.
add_filter("gform_confirmation", "custom_confirmation", 10, 4);
function custom_confirmation($confirmation, $form, $lead, $ajax){
//only change redirect for form id 64
if($form["id"] == "64"){
//my drop down with values to check is field 1; use field one out of the lead object
switch ($lead[1])
{
case "RG" :
$redirect_url = "http://www.rocketgenius.com";
break;
case "Google" :
$redirect_url = "http://www.google.com";
break;
default :
//set default redirect url
$redirect_url = "http://www.gravityforms.com";
break;
}
$confirmation = array("redirect" => $redirect_url);
}
return $confirmation;
}
Let me know if you have questions.
I am sort of a newby to coding in wordpress. I have a good background in code though. Where do I add this code. Does it go in the form_display.php, or does it go in the functions.php?, and where does it need to be placed it that code?
Thanks,
Julie
Hi, Julie,
You would put the code in your theme's functions.php file. I always add my hooks to the end of the file.
Do I set the form up as a redirect under settings? That only gives you one option to redirect to, I assume that is the default you want it to go to? Is that correct?
Never mind, I got it to work. That is so perfect.... THANK YOU!