Skip to content

Instantly share code, notes, and snippets.

@n1mh
Created January 29, 2018 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n1mh/ed0f647c3d573017e89f32171dde7442 to your computer and use it in GitHub Desktop.
Save n1mh/ed0f647c3d573017e89f32171dde7442 to your computer and use it in GitHub Desktop.
// how to get multiple redirections using DOM in Contact Form 7
// mandatory from January 2018. on_send_ok is deprecated.
// wp/wp-content/mytheme/functions.php
add_action( 'wp_footer', 'redireccion_contactform7' );
function redireccion_contactform7() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if( '82' == event.detail.contactFormId ) {
window.location.replace('https://example.com/thank-you/');
// ga('send', 'event', 'Contact Form', 'submit' );
}
//if( 'XX' == event.detail.contactFormId ) {
//window.location.replace('https://otherexample.com/thank-you/');
//}
}, false );
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment