Skip to content

Instantly share code, notes, and snippets.

@KustomDeveloper
Created October 10, 2018 17:48
Show Gist options
  • Select an option

  • Save KustomDeveloper/da434f78ea97018576cc5b5c34f26f25 to your computer and use it in GitHub Desktop.

Select an option

Save KustomDeveloper/da434f78ea97018576cc5b5c34f26f25 to your computer and use it in GitHub Desktop.
function redirect_cf7() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '947' == event.detail.contactFormId ) { // Sends sumissions on form 947 to the first thank you page
location = 'https://www.example.com/thank-you-1/';
} else if ( '1070' == event.detail.contactFormId ) { // Sends submissions on form 1070 to the second thank you page
location = 'https://www.example.com/thank-you-2/';
} else { // Sends submissions on all unaccounted for forms to the third thank you page
location = 'https://www.example.com/thank-you-3/';
}
}, false );
</script>
<?php
}
add_action( 'wp_footer', 'redirect_cf7' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment