WordPress

Contact form 7 redirects

Add the code to the functions.php and change the contactFormId as required and the page links to redirect.

add_action( 'wp_footer', 'redirect_cf7' );
 
function redirect_cf7() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
    if ( '20' == event.detail.contactFormId ) {
       location = '<?php echo home_url(); ?>/thank-you-for-applying/';
    } else {
        location = '<?php echo home_url(); ?>/thank-you/';     
    }
}, false );
</script>
<?php
}