I'm trying to redirect to another page after contact form submission button is clicked but it doesn't work. I'm trying it following the oficial guide https://contactform7.com/redirecting-to-another-url-after-submissions/ and putting this script:
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'http://example.com/';
}, false );
</script>
inside the additional preferences tab but it doesn't work. How can i solve this problem?
Copy this code and paste this into the functions.php file of your child themes
/**
* Redirect user to hard coded link when form data is submitted.
*/
function contact_form_login_redirect() {
?>
<script>
document.addEventListener( 'wpcf7mailsent', function ( event ) {
location = 'http://example.com/';
}, false );
</script>
<?php
}
add_action( 'wp_footer', 'contact_form_login_redirect' );
I tryed and it's working fine for me