Support » Plugin: Contact Form 7 » Contact Form 7 redirect URL not working

  • Resolved jensdes

    (@jensdes)


    I Have created a contact form on the page above… if you fill it out, it’s supposed to redirect the user to a thank you page where they have the option to download resources…. here’s the code I’m using in the “additional settings” part of my form:

    <script>
    document.addEventListener( ‘wpcf7submit’, function( event ) {
    location = ‘http://beta.rep.direct/why-rep-download-thank-you/&#8217;;
    }, false );
    </script>

    I’m not sure why it’s not working. Thanks

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter jensdes

    (@jensdes)

    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

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Thread Starter jensdes

    (@jensdes)

    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 9 months ago by jensdes.
    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where did you put the code into?

    Thread Starter jensdes

    (@jensdes)

    I mentioned that in my first post here. It’s in the advanced settings for the form.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Yeah I know. That explains why it doesn’t work.

    Read the document, please.

    Thread Starter jensdes

    (@jensdes)

    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

    Thread Starter jensdes

    (@jensdes)

    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.

    Thread Starter jensdes

    (@jensdes)

    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 9 months ago by jensdes.
    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Thread Starter jensdes

    (@jensdes)

    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/&#8217;;
    }, false );
    </script>

    Again, the URL posted here isn’t posting correctly.

    • This reply was modified 8 months, 3 weeks ago by jensdes.

    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.

    Thread Starter jensdes

    (@jensdes)

    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

    Thread Starter jensdes

    (@jensdes)

    <script>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    if ( ‘1558’ == event.detail.contactFormId ) }{
    location = ‘http://beta.rep.direct/why-rep-download-thank-you/&#8217;;
    }, 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 8 months, 3 weeks ago by jensdes.
    • This reply was modified 8 months, 3 weeks ago by jensdes.

    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>
Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Contact Form 7 redirect URL not working’ is closed to new replies.