• Dear all,

    on_sent_ok to redirect to another page, I got an error on only one website but not on the others with Contact Form 7
    What is the best way to resolve this issue.
    I try the trick on the functions.php but it doesn’t resolve the trouble.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Thread Starter georgerl

    (@georgerl)

    Hi,
    I try few things and none is working.
    I added in functions.php:

    add_action('wp_head', 'hook_javascript');
    function hook_javascript() {
        ?>
    <script>
    document.addEventListener( 'wpcf7mailsent', function( event ) {
        location = 'https://example.com/thank-you/';
    }, false );
    </script>
    <?php
    }
    

    in Contact Form Additional Settings:

    
    jQuery(document).ajaxComplete(function() {
      if (jQuery('.wpcf7-mail-sent-ok').length) {
        alert(1);
       window.location.replace("https://example.com/thank-you/");
      }
    });
    

    Can you tell me what is the best way

    • This reply was modified 7 years, 4 months ago by georgerl.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘on_sent_ok redirect’ is closed to new replies.