Contact form 7 — redirecting to a different page — by Steven Lacerda (Morgan Hill, CA)
1 min readAug 15, 2018
In contact forms 7, the on_sent_ok has been deprecated in favor of DOM events, which most javascript developers are familiar with. Here’s an example where I am redirecting my page after successful submission:
add_action( ‘wp_footer’, ‘mycustom_wp_footer’ );function mycustom_wp_footer() { ?> <script type=”text/javascript”> document.addEventListener( ‘wpcf7mailsent’, function( event ) { setTimeout(function() { location.replace(“http://n3n.io"); }, 2000); }, false ); </script> <?php}
I placed this code in my Avada Child Themes functions.php file.
As always, don’t be a prisoner to your code, master it!
Solving a problem is as good as those sexual feelings…sometimes, okay, maybe not. Straight from Morgan Hill, CA. Good luck!