WORDPRESS : Solve problem with ” Contact form 7 “, “Additional Settings” update and WPML

From some months, if you had set additional settings, on “additional settings” panel in ” Contact Form 7 ” , when you update the plugin, had an error:

This epends because the Javascript code for some of this additional settings is deprecated. ( if you don’t see any error notification , never mind, the actions you using aren’t deprecated ).

First of all remove the code in ” Additional Settings ” tab.
Second, open your function file from your theme and paste this code ( in this example use code for redirect on thank you page after submit ).

if you have only one form:


add_action( 'wp_footer', 'mycustom_wp_redirect' );
 
 function mycustom_wp_redirect() {
 ?>
 <script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {


    location = 'http://yourdomain.it/tanks-page-contatti/';

  
    }, false );
 </script>
<?php
}

If you want targeting a specific form:

add_action( 'wp_footer', 'mycustom_wp_redirect' );
 
 function mycustom_wp_redirect() {
 ?>
 <script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {



if ( '133' == event.detail.contactFormId ) {

    location = 'http://yourdomain.it/tanks-page-contatti/';

}
  
    }, false );
 </script>
<?php
}

If you have a simple form , without multi language ( in my case language are managed with WPML )That’s all.

If you try your form, you can see that work’s fine ( as before ).

If you use “WPML”, there’s something more to do.

Open your function.php, and change the before code :


add_action( 'wp_footer', 'mycustom_wp_redirect' );
 
 function mycustom_wp_redirect() {
 ?>
 <script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {



if ( '133' == event.detail.contactFormId ) {

    location = 'http://yourdomain.it/tanks-page-contatti/';

}else if ( '274' == event.detail.contactFormId ) {

     location = 'http://yourdomain.it/en/thanks-for-contacting-us/';

}else if ( '134' == event.detail.contactFormId ) {

      location = 'http://yourdomain.it/grazie-per-esserti-iscritto/';

}else if ( '272' == event.detail.contactFormId ) {

      location = 'http://yourdomain.it/en/thank-you-for-signing-up/';

}
  
    }, false );
 </script>
<?php
}

With this method you can add different thank you page for different language.

That’s all