If you use Contact Form 7 on your WordPress website, you may notice that after a visitor submits the form, the page suddenly redirects to a different URL or reloads. This breaks analytics, makes the form feel slow, and confuses users. The good news: it is almost always fixable in minutes.
This guide walks you through every common cause of the Contact Form 7 redirect after submit problem and shows you how to keep visitors on the same page with a clean success message instead.
Quick Troubleshooting Table
Symptom
Most likely cause
Fix
Page redirects to a thank-you URL after submit
Legacy on_sent_ok in Additional Settings
Delete the line from Additional Settings, save
Page redirects only after success
Redirect plugin (e.g. Redirection for Contact Form 7)
Turn off redirect rule or deactivate the plugin
Page reloads to home or admin-ajax.php
AJAX broken — wp_footer() missing or JS error
Add wp_footer() in footer.php; fix JS console errors
Custom redirect to /thank-you/
Custom wpcf7mailsent JS handler
Remove the JS in functions.php or theme files
Form fails silently after cache plugin update
Aggressive minify/defer breaking CF7 scripts
Exclude contact-form-7 JS from optimisation
Step 1: Remove Old Settings That Cause Redirects
Open your WordPress Dashboard.
Go to Contact → Contact Forms.
Edit the form that redirects.
Scroll down to Additional Settings.
If you see a line like on_sent_ok: "location = 'https://example.com/thank-you';", delete it.
Click Save.
Add a screenshot here of the Additional Settings field with the deprecated line highlighted.
The on_sent_ok hook was removed from Contact Form 7 years ago, but the line often survives form imports and theme migrations and silently breaks new sites.
Step 2: Check If a Plugin Is Redirecting the Form
Many sites install a helper plugin to add a redirect option back. If that helper is configured with a URL, it will keep redirecting even after you clear Step 1.
Go to Plugins → Installed Plugins.
Look for plugins like Redirection for Contact Form 7, CF7 Success Page Redirect or Contact Form 7 Multi-Step.
Open the plugin’s settings and either disable the redirect or delete the redirect rule attached to your form.
If the plugin is unused, deactivate it.
Add a screenshot here of the Redirection for Contact Form 7 settings panel.
Step 3: Look for JavaScript That Redirects the Page
Themes and developers often add a small JS snippet that listens for the wpcf7mailsent event and redirects manually. It looks like this:
Search your active theme files (functions.php, header.php, footer.php and JS assets) for wpcf7mailsent or window.location.
Remove or comment out the redirect handler.
If you cannot edit the theme directly, override the snippet from a child theme or a code snippet plugin.
Step 4: Make Sure AJAX Works Properly
Contact Form 7 submits via AJAX. If AJAX is broken, the browser falls back to a normal POST and the page reloads — which feels like a redirect.
Open your theme’s footer.php. Confirm <?php wp_footer(); ?> is called just before </body>.
In Chrome or Firefox, open DevTools (F12) → Console and submit the form. Fix any red errors first.
In Network, watch for the admin-ajax.php request — it should return JSON, not a redirect.
If a cache, minify or “defer JS” plugin is active, exclude contact-form-7 scripts from optimisation and clear the cache.
Step 5: Verify the Fix
Once the cleanup is done, your form should:
Stay on the same page after submit.
Show the configured success message (“Thank you for your message”).
Only redirect when you explicitly want it to.
Bonus: Send Every Form Submission to Your CRM
Fixing the redirect is half the job. The other half is making sure no submission is lost. Even with a working form, emails get filtered to spam, inboxes get full, and replies get missed. HamaraCRM® connects to Contact Form 7 and turns every submission into a tracked lead or ticket — with WhatsApp and call follow-ups built in.
It usually redirects because of a legacy on_sent_ok line in the form's Additional Settings, a redirect plugin (such as Redirection for Contact Form 7), or a custom wpcf7mailsent JavaScript handler in functions.php or the theme.
Is on_sent_ok still supported in Contact Form 7?
No. The on_sent_ok hook was removed years ago. If it is still in your Additional Settings, delete it and save the form — that alone often fixes the redirect.
How do I stop a JavaScript redirect on wpcf7mailsent?
Search your theme files (functions.php, header.php, footer.php and JS assets) for "wpcf7mailsent" or "window.location". Remove or comment the redirect handler, then clear cache.
My form reloads the whole page instead of showing the success message — why?
AJAX is not running. Make sure your theme calls wp_footer() before the closing tag, no JavaScript error is breaking the page, and any aggressive optimisation or cache plugin is not stripping Contact Form 7 scripts.
Will HamaraCRM® capture these form submissions?
Yes. HamaraCRM® ships a Contact Form 7 connector and a ticketing system that captures every submission as a lead or ticket so nothing slips through.