When I pasted my code, it change the redirect URL :-(…
it is: http://beta.rep.direct/why-rep-download-thank-you/ (everything after / including the extra ; is not in my contact form settings. Thanks
Hi Takayuki, I already used that code to begin with and it didn’t work, which is what prompted me to search DOM options and choose the form option.
To clarify, the form is not triggering an email…. it’s just collecting the form info and redirecting. Perhaps I’m misunderstanding the ‘wpcf7mailsent’ function…. thanks.
I’m happy to send a screenshot of my contact form settings if helpful.
-
This reply was modified 2 years, 1 month ago by
jensgoddess.
Where did you put the code into?
I mentioned that in my first post here. It’s in the advanced settings for the form.
Yeah I know. That explains why it doesn’t work.
Read the document, please.
The theme’s section for code, right? I tried putting it there also and it didn’t work. I’ll have to try it tomorrow again as I’m not at work right now. But I did try putting it there. Thanks
I see now I had it in the wrong place… I figured it out. I had put it in the CSS custom code section for the theme instead of the custom javascript. Thanks for your help. Merry Christmas.
Hi sorry! So… the code is working… however, I have another contact form that I DO NOT want to redirect in this way. So how to I stipulate which forms to redirect to my URL and which ones not? Thanks for your help.
The contact form ID of the form I WANT included in the code is id 1558.
The form I don’t want included is id 1612.
-
This reply was modified 2 years, 1 month ago by
jensgoddess.
I did my best to add the ID to my code, but it’s not working. If you have any suggestons. Thank you.
<script>
document.addEventListener( ‘wpcf7mailsent’, function( event ) {
if ( ‘1558’ == event.detail.contactFormId ) {
location = ‘http://beta.rep.direct/why-rep-download-thank-you/’;
}, false );
</script>
Again, the URL posted here isn’t posting correctly.
-
This reply was modified 2 years, 1 month ago by
jensgoddess.
Your code as posted here, and on http://beta.rep.direct/why-rep-download-thank-you/ is incorrect. The if
statement is missing a closing curly brace.
I’m sorry… I appreciate your help, but I’m not a coder… I understand enough to copy and paste. Would I put it after the closed parenthesis of the event.detail.contactFormID ) ? Thanks Jen
<script>
document.addEventListener( ‘wpcf7mailsent’, function( event ) {
if ( ‘1558’ == event.detail.contactFormId ) }{
location = ‘http://beta.rep.direct/why-rep-download-thank-you/’;
}, false );
</script>
This is what I changed it to… it’s not working.
I understood the initial function and I understood the DOM event I needed to use but I wasn’t clear on how to combine them. Thanks
-
This reply was modified 2 years, 1 month ago by
jensgoddess.
-
This reply was modified 2 years, 1 month ago by
jensgoddess.
To fix the syntax error the closing curly brace needs to come after setting location
.
<script>
document.addEventListener('wpcf7mailsent', function(event){
if ('1558' == event.detail.contactFormId){
location = '...';
}
}, false );
</script>