Hide the Contact Form 7 Form After It Is Sent
Hides the fields of a Contact Form 7 form once it has been sent successfully and leaves only the thank-you message, so people do not submit twice.
Opens WPIDE on
Code
.wpcf7 form.sent > *:not(.wpcf7-response-output) {
display: none;
}
.wpcf7 form.sent .wpcf7-response-output {
margin: 0;
padding: 1rem 1.25rem;
font-size: 1.05em;
}
Notes
Contact Form 7 adds the "sent" class to the form after a successful submission; reloading the page shows the form again.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.