• Skip to main content
  • Skip to footer

EqualServing

WooCommerce, ActiveCampaign, 1ShoppingCart, Infusionsoft Expertise.

  • Services
    • Build Websites
    • Task Automation
      • ActiveCampaign Marketing Automation
      • Process Automation with Infusionsoft
    • Website Content Migration
    • Service Bundles
    • Third Party Software Integration
    • WordPress Plugin Development
  • About Us
  • Contact
  • Blog
  • Shop
    • Service Bundles
    • WordPress Plugin For 1ShoppingCart.com V2.0
    • WordPress Themes
    • All Our WordPress Plugins
  • Support
    • FAQ – 1ShoppingCart Plugin For WordPress – GENERAL
    • FAQ – 1ShoppingCart Plugin For WordPress – FREE
    • FAQ – 1ShoppingCart Plugin For WordPress – PREMIUM
    • Contact Support
You are here: Home / How To / Infusionsoft: Redirecting After Submitting Web Form Version 2

Infusionsoft: Redirecting After Submitting Web Form Version 2

March 7, 2015 by Michele Leave a Comment

I was asked today how could I route users to different pages using the value of a dropdown list and thought my original version of the routing function would work perfectly but it did not. It required a little tweaking but here you go…

Infusionsoft Web Form

For my example, I created another simple Web Form at https://fr381.infusionsoft.com/app/form/interests1. I set the Thank You page for this form as a Web Address -> http://clients.equalserving.com/loreen/infusionsoft-router-v2/

Shortcode Verion 2

Version 2 of the shortcode –

[esifs_router_v1 field_name="inf_custom_BlogInterests" pages = '{"Digital Downloads":"https://www.equalserving.com/category/digital-downloads/","Infusionsoft":"https://www.equalserving.com/category/infusionsoft/","How Tos":"https://www.equalserving.com/category/how-to/"}']

Where the field_name (inf_custom_BlogInterests) that I want to interrogate is named and the values of the choices (Digital Downloads, Infusionsoft, How Tos) and the pages I want visitors redirected to follow in the variable pages.

SelectRedirect to Page
Digital Downloadshttps://www.equalserving.com/category/digital-downloads/
Infusionsofthttps://www.equalserving.com/category/infusionsoft/
How Toshttps://www.equalserving.com/category/how-to/

If you take a peek at the source code of my web form, you will notice that each of the items in the dropdown has the values that you entered in the field in the Infusionsoft web form builder.

<div class="infusion-field"> 
   <label for="inf_custom_BlogInterests">Blog Interests *</label> 
   <select id="inf_custom_BlogInterests" name="inf_custom_BlogInterests">
      <option value="">Please select one</option>
      <option value="Digital Downloads">Digital Downloads</option>
      <option value="Infusionsoft">Infusionsoft</option>
      <option value="How Tos">How Tos</option>
   </select> 
</div> 

To enable the use of such a shortcode requires that I add a function to my WordPress theme’s function.php file. I’ll explain what the following code does line by line below.

add_shortcode('esifs_router_v2', 'esifs_router_v2_function');
 
function esifs_router_v2_function($atts, $content = null){
    //* What is the IFS field name we are concerned with that predicts the routing
    if ((isset($atts["field_name"]) && $atts["field_name"] != "") && (isset($atts["pages"]) && $atts["pages"] != "")) {
        //* Convert the pages to a proper array
        $pages = json_decode( $atts["pages"], true );
        if( !is_array( $pages ) or count( $pages )<1 ) $pages = array();

        //* Get the value of the IFS field
        $field_name = $atts["field_name"];

        //* Make sure there is a value
        if (isset($_GET[$field_name]) && $_GET[$field_name] != "") {
            $value = $_GET[$field_name];
            $url = $pages[$value];
            if ($url != "") {
                $string .= '<script type="text/javascript">';
                $string .= 'window.location = "' . $url . '"';
                $string .= '</script>';
                echo $string;
            } else {
                echo "<p>No value found.</p>";
            }
        }
    }
}
  • Line 1: Associates the shortcode [esifs_router_v2] with the function esifs_router_v2_function. WordPress now knows that when it sees the shortcode [esifs_router_v2] in a page or post, it will call the esifs_router_v2_function. For more on WordPress shortcodes, you can read Smashing Magazines guide on shortcodes.
  • Line 3: passes the attributes from the shortcode to the function esifs_router_v2_function.
  • Line 5: checks to ensure that the field name is set in the shortcode and not empty.
  • Line 7 – 8: converts the details of the pages parameter into an array to use in the rest of the code.
  • Line 11: tells the function what field name I want to check for redirection. In my case, it is the field name inf_option_MyInterest.
  • Line 14: checks to ensure that the field name is being passed to the page by Infusionsoft and that the value is not empty.
  • Lines 15: assign the value of the option the visitor selected to the variable $value.
  • Lines 16: assigns the appropriate URL to the variable $url.
  • Lines 18 – 21: Will output a small piece of Javascript to the page that will redirect the visitor to the page you defined in the shortcode.
  • Lines 22 – 23: If a URL is not found in the array, it will output a message without the JavaScript code to redirect.

To finish this post I wanted to show you how to change the shortcode from my original example so that I could use the new version of the shortcode.

The new shorcode would look like –

[esifs_router_v2 field_name="inf_option_MyInterest" pages='{"213":"http://clients.equalserving.com/loreen/infusionsoft-router/213-kayaking", "215":"http://clients.equalserving.com/loreen/infusionsoft-router/215-biking", "217":"http://clients.equalserving.com/loreen/infusionsoft-router/217-hiking"}']

Filed Under: How To, Infusionsoft

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Footer

Stay Connected

Stay up to date with the latest news, product announcements, and more by signing up for our email newsletter. Don't forget to follow us on your favorite social sites as well.
  • Email
  • Google+
  • LinkedIn
  • RSS
  • Twitter
  • YouTube

Contact Us

EqualServing

46 Amethyst Rd
Palmyra, VA 22963

727-490-7443 https://www.equalserving.com/wp-content/uploads/2013/11/eslogo_300x60.png $$
Email :: Plugin Support
  • ActiveCampaign
  • How To
  • WooCommerce
  • WordPress Explained
  • Resources and Recommendations

Copyright © 2021 · Web Development :: EqualServing.com on Genesis Theme Framework
» You will find affiliate links on this site. When we find a company or individual that consistently delivers a high quality product or service, we will become an affiliate. «