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
-
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' => 'https://123.com/us/', 'Germany' => 'https://123.com/de/', ); if( isset( $url_map[ $country_of_residence ] ){ return $url_map[ $country_of_residence ]; } return $returl; }
-
This reply was modified 7 years, 8 months ago by
Nick Ciske.
Thank you so much Nick.
I will try that and let you know how it went.
Best,
Benoit
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/’,
‘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;
}
?>
However, it didn’t work….. Any idea what could be the problem?
Thank you,
Benoit
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; }
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
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’,
‘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;
}
?>
Thanks again for your help ^^
Best regards,
Benoit
-
This reply was modified 7 years, 8 months ago by
- The topic ‘Multiple Return Url’ is closed to new replies.