I have a form that’s inserted into a template using shortcode
<?php echo do_shortcode('[contact-form-7 id="370" title="Contact form 1"]') ?>
I’m trying to setup an event so that when the form is submitted I can redirect the user to another page. I’m using the following;
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'http://example.com/';
}, false );
</script>
The problem is, when you submit the form, the whole page is reloaded so the event is never triggered because the form isn’t submitted via an ajax call.
This is the first time I’m trying to integrate a form into WordPress, so I think I may have missed something. There are no errors in the developer console in Chrome.
2
Answers
My theme was missing;
Adding that solved the issue.
Somewhere in your theme (check functions.php) or your wp-config.php file, you need to look for and remove the following:
functions.php
config.php
These lines would prevent the default behavior of CF7.