Gravity Forms is a great plugin with huge functionality that I use on almost all of my websites. It just works and if there is ever a time when you cannot get it to do something that you want you can almost always find a solution through their support forums.
Recently I was trying to find a way to redirect my users to a specific url depending on which drop down they chose. Once they submitted the form they would then be redirected to a certain url. I used this to create a way for users to choose a purchase item in Gravity Forms and then they would be directed to a Woocommerce page within my site to actually pay for that item.
So, how did I accomplish this? After doing some searching around the web (http://www.gravityhelp.com/forums/topic/conditional-redirect-2#post-80796) I took the directions from several sites and came up with the following snippet that works well.
Add this to your functions.php file.
// GRAVITY FORMS REDIRECT // THIS WILL REDIRECT THE USER TO WHATEVER URL THEY SPECIFY AFTER SUBMITTING YOUR FORM // http://www.gravityhelp.com/forums/topic/conditional-redirect-2#post-80796 // change the 1 here to your form ID if you are not using form 1 add_filter('gform_confirmation_3', 'conditional_confirmation', 10, 4); function conditional_confirmation($confirmation, $form, $lead, $ajax){ // change the 1 here to your field if the unit numbers not field 1 $url = get_bloginfo(); // set a reasonable default in case we forget a unit switch($lead[fusion_builder_container hundred_percent="yes" overflow="visible"][fusion_builder_row][fusion_builder_column type="1_1" background_position="left top" background_color="" border_size="" border_color="" border_style="solid" spacing="yes" background_image="" background_repeat="no-repeat" padding="" margin_top="0px" margin_bottom="0px" class="" id="" animation_type="" animation_speed="0.3" animation_direction="left" hide_on_mobile="no" center_content="no" min_height="none"][1]) { case 'Name of Drop Down 1': $url = "http://www.google.com"; break; case 'Name of Drop Down 2': $url = "http://www.yahoo.com/"; break; } $confirmation = array('redirect' => $url); return $confirmation; }
The things you need to change:
- On line 6 – Change “gform_confirmation_3” to the correct form ID number. So all you are really changing here is the number “3” to your form number.
- On Line 12 – Change “Name of Drop Down 1” to the EXACT name of your drop down select item.
- On Line 13 – Change the url for “http://www.google.com” to the url you want to redirect the user.
That’s it![/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]
The post Redirect Users After Submitting a Gravity Form appeared first on Moore Web Exposure.