Request for Multiple External ReDirects
-
First off, thanks very much for having created this easy to use plugin. It works as designed. Can you in an upcoming version (soon) enable MULTIPLE redirects.
USE CASES
When someone completes a form, not only do I want them redirected to a Thanks page, but I also frequently want to serve them up MULTIPLE PDF’s of software products we implement.
I tried adding a <CR> after the first external reference but the <CR> saved the changes instead of adding a Line Fee.
Is there a work around you can suggest?
Please reply to [email protected] or [email protected]
Thanks in advance
-
Hi
Is this method updated? do not work for me
inputs = event.detail.inputs; inputs.forEach( function(el) { if ( el.name == 'your_redirect_page' ) { if ( el.value == 'Home' ) { location.href = 'http://yoursite.com/'; } else if ( el.value == 'About' ) { location.href = 'http://yoursite.com/about/'; } } });JS console shows the following error:
VM6242:12 Uncaught SyntaxError: missing ) after argument list at HTMLDocument.<anonymous> (wpcf7-redirect-script.js:12) at Object.wpcf7.triggerEvent (scripts.js?ver=5.0.3:372) at ajaxSuccess (scripts.js?ver=5.0.3:288) at Object.<anonymous> (scripts.js?ver=5.0.3:355) at i (jquery.js?ver=1.12.4:2) at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2) at y (jquery.js?ver=1.12.4:4) at XMLHttpRequest.c (jquery.js?ver=1.12.4:4) (anonymous) @ wpcf7-redirect-script.js:12 wpcf7.triggerEvent @ scripts.js?ver=5.0.3:372 ajaxSuccess @ scripts.js?ver=5.0.3:288 (anonymous) @ scripts.js?ver=5.0.3:355 i @ jquery.js?ver=1.12.4:2 fireWith @ jquery.js?ver=1.12.4:2 y @ jquery.js?ver=1.12.4:4 c @ jquery.js?ver=1.12.4:4 XMLHttpRequest.send (async) send @ jquery.js?ver=1.12.4:4 ajax @ jquery.js?ver=1.12.4:4 wpcf7.submit @ scripts.js?ver=5.0.3:346 (anonymous) @ scripts.js?ver=5.0.3:53 dispatch @ jquery.js?ver=1.12.4:3 r.handle @ jquery.js?ver=1.12.4:3Any suggestion?
Hi @richardmaximun,
It still works. Care to provide a link?
You have an extra
}
Code should be:inputs = event.detail.inputs; inputs.forEach( function(el) { if ( el.name == 'your_redirect_page' ) { if ( el.value == 'Antivirus' ) { location.href = 'https://www.bullguard.com/thankyou.aspx?pid=25&action=download'; } else if ( el.value == 'Internet Security' ) { location.href = 'https://www.bullguard.com/thankyou.aspx?pid=3&action=download'; } else if ( el.value == 'Premium Protection' ) { location.href = 'https://www.bullguard.com/thankyou.aspx?pid=33&action=download'; } } });Thank you very much @yuvalsabar
too much computer yesterday …. 😉
This works fine for me.
However, I’d like to redirect visitors to a page based on their input.
Say I have 2 variables: their age (3 age groups: young, middle-aged, old) and their interests (3 fields of interest: books, movies, music).
So, there are a 9 combinations possible.
If someone is young, and interested in music, I’d want to redirect him to a page about Kanye West
If somone is young, and interested in books, I’d want to redirect him to a page about Harry Potter.
If momeone is young and interested in movies, I’d want to redirect him to a page about the movie The Hunger games etc.Is this possible?
Suggestions are much appreciated.
Hi @janbletz,
Yes, you need to use the code above with just a little bit of adjustments. It’s the same principle.
Thank you!
I thought so, but was not sure since I couldn’t get it to work. I’ll try again.
I just can’t make it work.
In the form, I have added
[select your_redirect_page “Home” “About”][select age_group “Young” “Old”]
In the redirect settings, I have checked ‘Use external URL’
Now the javascript I have cobbled together:
inputs = event.detail.inputs; inputs.forEach( function(el) { if ( el.name == 'your_redirect_page' ) { if ( el.value == 'Home' ) && if (el.name=='age_group' && (el.value=='Young') { location.href = 'http://yoursite.com/about/'; } else if ( el.value == 'About' ) { location.href = 'http://yoursite.com/about/'; } } });The message gets sent, but the user is not redirected to HOME (if he chooses Home and is young).
What am I doing wrong?
Eh… I meant (but this doesn’t work either):
inputs = event.detail.inputs;
inputs.forEach( function(el) {
if ( el.name == ‘your_redirect_page’ ) {
if ( el.value == ‘Home’ ) && if (el.name==’age_group’ && (el.value==’Young’) {
location.href = ‘http://yoursite.com’;
} else if ( el.value == ‘About’ ) {
location.href = ‘http://yoursite.com/about/’;
}
}
});-
This reply was modified 7 years, 9 months ago by
janbletz.
To whom it might concern: a professional programmer figured it out for me. Pretty neat. Here’s the code we used (comments in Dutch):
The form:
<label> Your Name (required) [text* your-name] </label> <label> Your Email (required) [email* your-email] </label> Je levensfase [checkbox* levensfase exclusive "(Bijna) student" "Bezig een carrière op te bouwen" "(Bijna) klaar met mijn carrière"] Je interesse gaat vooral uit naar [checkbox* interesse exclusive "(Flex)student worden" "(Flex)docent worden" "Me voorbereiden op een volgende carrièrestap" "Weet niet"] <label> Your Message [textarea your-message] </label> [submit "Send"]The javascript in the redirection tab:
//roep de inhoud van de gesubmitte form aan document.addEventListener( 'wpcf7submit', function( event ) { //stop alle ingevulde waarden (value), alsmede de onderdelen waar de waarden bij horen (name) in de variable/array inputs var inputs = event.detail.inputs; //doorloop de variabele/array inputs om de ingevulde waarde (inputs.value) bij de (input.name) levensfase te vinden for ( var i = 0; i < inputs.length; i++ ) { if ( 'levensfase' == inputs[i].name ) { $levensfase = inputs[i].value; } } //doorloop de variabele/array inputs om de ingevulde waarde (inputs.value) bij de (input.name) interesse te vinden for ( var i = 0; i < inputs.length; i++ ) { if ( 'interesse' == inputs[i].name ) { $interesse = inputs[i].value } } //onderstaand kun je een optie toevoegen plus de url's: "if ($levensfase == "VulOptieIn") {document.location.href="URL";}" OF //meerdere opties: "if ($levensfase == "VulOptieIn" && $interesse == "VulOptieIn") {document.location.href="URL";}" if($levensfase == "(Bijna) student" && $interesse == "(Flex)student worden") {document.location.href="http://example.com";} if($levensfase == "Bezig een carrière op te bouwen" && $interesse == "(Flex)docent worden") {document.location.href="http://google.nl";} }, false );“janbletz ” last solution works! Thank you very much!!!
I have used ‘ instead of ” and just ignored the comments in dutch.
This is exactly what I needed.
Thank you again! -
This reply was modified 7 years, 9 months ago by
The topic ‘Request for Multiple External ReDirects’ is closed to new replies.