Skip to content

Instantly share code, notes, and snippets.

@mrfoxtalbot
Created January 19, 2018 11:44
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 mrfoxtalbot/b02a0f04edcb7fa568dcaaad60b20edf to your computer and use it in GitHub Desktop.
Save mrfoxtalbot/b02a0f04edcb7fa568dcaaad60b20edf to your computer and use it in GitHub Desktop.
Redirigir a otra página después de enviar un formlario de Contact Form 7 (distinguir a dónde si tienes varios formularios)
<?php add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
?>
<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 }
// source: https://www.rocketclicks.com/client-education/contact-form-7-thank-page-redirects/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment