1
I have some forms using the plugin contact form 7 and each one redirecting to a specific success page, I used on_sent_ok, however it does not work I went to check and found that it is obsolete and the correct now is to use the gift, but nothing happens when trying to put the gift.
I’m trying to use the following code, include it in functions.php:
add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
?>
<script>
document.addEventListener( 'wpcf7submit', function( event ) {
if ( '238' == event.detail.contactFormId ) {
location = 'http://www.site.com.br/sucesso1';
}else if ( '235' == event.detail.contactFormId ) {
location = 'http://www.site.com.br/sucesso2';
}
}, false );
</script>
<?php
}
Still nothing returns so as if it were get in the url this parameter site.com.br/#wpcf7-f238-p242-O1
– Fernando
I made a change, if it doesn’t work I will remove my reply @Fernando
– Wictor Chaves
didn’t work I thought it was by conflict so I adapted the code, but so far nothing
– Fernando
add_action( 'wp_footer', 'mycustom_wp_footer' ); Function mycustom_wp_footer() { ? > <script> var $Jquery = jQuery.noConflict() $Jquery(Document.addeventlistener('wpcf7submit', Function( Event ) { if ( '238' == Event.detail.contactFormId ) { window.Location = 'http://www.site.com.br/success1'; }Else if if ( '235' == Event.detail.contactFormId ) { window.Location = 'http://www.site.com.br/success2'; } }, false ); </script> <? php }
– Fernando