Site logo

Archived topic

code in footer.php

7 replies · Started by Matthew on June 7, 2019

Viewing posts 1–8 of 8

I have been told to add below snippet to the footer.php, and doing so will enable CF7 plugin to not clear the form field values from all the fields in a form after its submitted.

<script>
document.addEventListener( ‘wpcf7mailsent’, function( event ) {
jQuery(‘.wpcf7’).find(‘form’)[0].reset();
}, false );
</script>

I added the above code as displayed into footer.php, but it's not working. Am I doing something wrong? Should it be put in a certain area of the php file?

I copied footer.php into my child theme folder first, then pasted the code into that.

Also tried it with php open and close tags (instead of 'script')

It seems weird to add this to the footer. Should it not be functions.php?

thanks,

Hi David,

thanks for the info about Elements. Learnt something new.

Did exactly as you said but not working though. Can only assume the CF7 core file code is still overriding it

wp-content\plugins\contact-form-7\includes\js\scripts.js

`if ( 'mail_sent' == data.status ) {
$form.each( function() {
this.reset();
} );`

It could be. Where did you get the other code from? Does the provider of that provide any explanation?

I have just sent a support request about it to them,

Let us know what they come back with

Glad to hear you found a solution.

This archived topic is closed to new replies.