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?

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 ) {
if ( '3648' == event.detail.contactFormId ) {
location = ''; }
}, 20000);
}, false );


Make these edits accordingly:

3648         –  contact form 7 id if this is for specific form only         –  your url goes here

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

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.