Trick to delay wordpress contact form 7 redirect with Javascipt

i’m using the Contact form 7 Redirect, when a new user signs up. When the user signs up a message is displayed, but the redirect happens instant, so there is no time to read the message. Is there a way to delay the redirect with Javascipt?

0
Badge 2 Asked on May 20, 2019 in Wordpress.
Add Comment
1 Answer(s)

Try to use this code,

You can put the code on functions.php file.

add_action( 'wp_footer', 'redirect_cf7' );
function redirect_cf7() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
setTimeout(function(){
if ( '3648' == event.detail.contactFormId ) {
location = 'https://www.q-glue.com/luma-institute/'; }
}, 20000);
}, false );
</script>
<?php
}

 

Make these edits accordingly:

3648         –  contact form 7 id if this is for specific form only

https://www.q-glue.com/luma-institute/         –  your url goes here

20000          – Replace location and 20000(ms) as your wish

0
Badge 2 Answered on May 20, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.