Contact form 7 — redirecting to a different page — by Steven Lacerda (Morgan Hill, CA)

Steven Lacerda
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!

— by Steven Lacerda

--

--

Steven Lacerda
Steven Lacerda

Written by Steven Lacerda

Steve Lacerda is a software engineer specializing in web development. His favorite 80’s song is Let’s Put the X in Sex by Kiss.

No responses yet