Title: Multiple Return Url
Last modified: June 20, 2017

---

# Multiple Return Url

 *  Resolved [benoitmarie9](https://wordpress.org/support/users/benoitmarie9/)
 * (@benoitmarie9)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/multiple-return-url/)
 * Hi,
 * I would like to know if it is possible to add multiple return url to one specific
   Web-to-lead form?
 * In my case, I have created a custom “Country of Residence” field with a list 
   of countries. What I would like to achieve is to redirect users on a different
   thank you page depending on the country they selected.
 * Any feedback would be most appreciated, thank you.
 * Ben

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Nick Ciske](https://wordpress.org/support/users/nickciske/)
 * (@nickciske)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/multiple-return-url/#post-9248949)
 * Not with the UI.
 * This filter would allow you to change it based on a field value:
 * **salesforce_w2l_returl**
 * **salesforce_w2l_returl_{Form ID}**
 * Allows you to filter the value of a field before it is output to dynamically 
   populate it with a value, auto set it based on another value, etc.
 * Examples:
 *     ```
       // Filter Return/Success URL on a specific form
       // salesforce_w2l_returl_{Form ID}
       add_filter( 'salesforce_w2l_returl', 'salesforce_w2l_returl_1_tester_example', 10, 1 );
       function salesforce_w2l_returl_1_tester_example(  $returl ){
   
       $country_of_residence = $_POST['Country_of_Residence__c']; // change this to the name of your custom field
   
       // add/remove elements below to map countries to URLs
       $url_map = array(
       'United States' => 'http://123.com/us/',
       'Germany' => 'http://123.com/de/',
       );
   
       if( isset( $url_map[ $country_of_residence ] ){
           return $url_map[ $country_of_residence ];
       }
   
       return $returl;
   
       }
       ```
   
    -  This reply was modified 8 years, 9 months ago by [Nick Ciske](https://wordpress.org/support/users/nickciske/).
 *  Thread Starter [benoitmarie9](https://wordpress.org/support/users/benoitmarie9/)
 * (@benoitmarie9)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/multiple-return-url/#post-9254702)
 * Thank you so much Nick.
 * I will try that and let you know how it went.
 * Best,
 * Benoit
 *  Thread Starter [benoitmarie9](https://wordpress.org/support/users/benoitmarie9/)
 * (@benoitmarie9)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/multiple-return-url/#post-9265771)
 * Hi Nick,
 * Thanks again for taking the time to assist me on this. I really appreciate it.
 * I followed your example and ended up with the following code that I inserted 
   in my child theme function.php file (my webform id is “12”):
 * // Filter Return/Success URL on a specific form
    // salesforce_w2l_returl_{Form
   ID} add_filter( ‘salesforce_w2l_returl’, ‘salesforce_w2l_returl_12’, 10, 1 );
   function salesforce_w2l_returl_12( $returl ){
 * $country_of_residence = $_POST[‘Country_of_residence__c’]; // change this to 
   the name of your custom field
 * // add/remove elements below to map countries to URLs
    $url_map = array( ‘Saudi
   Arabia’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217);,‘
   Kuwait’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217);,‘
   United Arab Emirates’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217);,‘
   Oman’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217);,‘
   Jordan’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217);,‘
   Bahrain’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/&#8217);,);
 * if( isset( $url_map[ $country_of_residence ] )){
    return $url_map[ $country_of_residence];}
 * return $returl;
 * }
 * ?>
 * However, it didn’t work….. Any idea what could be the problem?
 * Thank you,
 * Benoit
 *  Plugin Author [Nick Ciske](https://wordpress.org/support/users/nickciske/)
 * (@nickciske)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/multiple-return-url/#post-9265809)
 * You’re almost there… try this instead:
 *     ```
       // Filter Return/Success URL on a specific form
       // salesforce_w2l_returl_{Form ID}
       add_filter( 'salesforce_w2l_returl_12', 'map_country_to_return_url', 10, 1 );
       function map_country_to_return_url( $returl ){
   
       	$country_of_residence = $_POST['Country_of_residence__c']; // change this to the name of your custom field
   
       	// add/remove elements below to map countries to URLs
       	$url_map = array(
       	'Saudi Arabia' => 			'https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/',
       	'Kuwait' => 				'https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/',
       	'United Arab Emirates' => 	'https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/',
       	'Oman' => 					'https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/',
       	'Jordan' => 				'https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/',
       	'Bahrain' => 				'https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426/',
       	);
   
       	if( isset( $url_map[ $country_of_residence ] )){
       		return $url_map[ $country_of_residence ];
       	}
   
       return $returl;
   
       }
       ```
   
 *  Thread Starter [benoitmarie9](https://wordpress.org/support/users/benoitmarie9/)
 * (@benoitmarie9)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/multiple-return-url/#post-9265898)
 * Hi Nick,
 * Really sorry to bother you with this. I did update the code with the above but
   the result remains identical.
 * If I am setting a return url from the plugin I will be systematically redirected
   on it (even if I select one of the country listed in function.php).
 * If I don’t set a return url from the plugin I will be redirected on the basic
   success page on my website.
 * I rechecked all the elements that could potentially create a problem and they
   are all correct:
 * 1- “Country_of_residence__c” field name
 * 2- Form id (12)
 * 3- Countries names based on their Salesforce values
 * Thank you very much ^^
 * Benoit
 *  Thread Starter [benoitmarie9](https://wordpress.org/support/users/benoitmarie9/)
 * (@benoitmarie9)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/multiple-return-url/#post-9269082)
 * Hi Nick,
 * The code finally worked. Actually, it worked since the latest version you sent
   me but the form id was wrong. I was taken it from Salesforce directly and not
   from the form within the plugin:
 * // Filter Return/Success URL on a specific form
    // salesforce_w2l_returl_{Form
   ID} add_filter( ‘salesforce_w2l_returl_12’, ‘map_country_to_return_url’, 10, 
   1 ); function map_country_to_return_url( $returl ){
 *  //$country_of_residence = $_POST[‘Country_of_residence__c’]; // change this 
   to the name of your custom field
    $country_of_residence = $_POST[’00N0Y00000Fm3IX’];
 *  // add/remove elements below to map countries to URLs
    $url_map = array( ‘Saudi
   Arabia’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217);,‘
   Kuwait’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217);,‘
   United Arab Emirates’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217);,‘
   Oman’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217);,‘
   Jordan’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217);,‘
   Bahrain’ => ‘[https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217](https://www.interactivebrokers.com/Universal/servlet/OpenAccount.IBrokerGuestLogin?partnerID=I2093204&invitedBy=&template=FX+CFD+only&invitation_id=21066426&#8217);,);
 *  if( isset( $url_map[ $country_of_residence ] )){
    return $url_map[ $country_of_residence];}
 * return $returl;
 * }
 * ?>
 * Thanks again for your help ^^
 * Best regards,
 * Benoit

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Multiple Return Url’ is closed to new replies.

 * ![](https://ps.w.org/salesforce-wordpress-to-lead/assets/icon-256x256.png?rev
   =2316786)
 * [Brilliant Web-to-Lead for Salesforce](https://wordpress.org/plugins/salesforce-wordpress-to-lead/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/salesforce-wordpress-to-lead/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/salesforce-wordpress-to-lead/)
 * [Active Topics](https://wordpress.org/support/plugin/salesforce-wordpress-to-lead/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/salesforce-wordpress-to-lead/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/salesforce-wordpress-to-lead/reviews/)

## Tags

 * [thank you page](https://wordpress.org/support/topic-tag/thank-you-page/)
 * [web to lead](https://wordpress.org/support/topic-tag/web-to-lead/)

 * 6 replies
 * 2 participants
 * Last reply from: [benoitmarie9](https://wordpress.org/support/users/benoitmarie9/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/multiple-return-url/#post-9269082)
 * Status: resolved