Skip to content

Instantly share code, notes, and snippets.

@marklchaves
Created August 4, 2024 15:42
Show Gist options
  • Save marklchaves/b0dbca64ac2ee89d8dcb358e624baa32 to your computer and use it in GitHub Desktop.
Save marklchaves/b0dbca64ac2ee89d8dcb358e624baa32 to your computer and use it in GitHub Desktop.
After submit, hide the Contact Form 7 form so only the success message shows then redirect after 3 seconds
document.addEventListener( 'wpcf7mailsent', function( event ) {
document.querySelectorAll("form.wpcf7-form > :not(.wpcf7-response-output)").forEach(el => {
el.style.display = 'none';
});
// Redirect on submission
setTimeout( () => {
location = '/my-redirect-page/'; // TO DO: Put your URL or slug here.
}, 3000 ); // Wait for 3 seconds to redirect. Change the delay to what you want.
}, false );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment