Skip to content

Instantly share code, notes, and snippets.

@gaupoit
Last active July 2, 2019 08:27
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 gaupoit/920551fb11c53c6afe9b5cbb4dc45f74 to your computer and use it in GitHub Desktop.
Save gaupoit/920551fb11c53c6afe9b5cbb4dc45f74 to your computer and use it in GitHub Desktop.
PHP Snippet to implement the contact form redirection
add_action( 'wp_footer', 'redirect_cf7' );
function redirect_cf7() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '1460' == event.detail.contactFormId ) { // Sends sumissions on form 1460 to the custom thank you page
location = 'https://example.com/thank-you/';
}
}, false );
</script>
<?php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment