[Plugin: Contact Form 7] How to: Redirect after submit
-
Just wanted to share how I do my redirects with Contact Form 7 as the official solution to this isn’t very satisfying for a number of reasons (especially the dependance on JavaScript).
I’d love to put this in an already existing thread here, but they’re all closed already.
Anyway! No source hacks involved, it relies on an action added by CF7 itself, no JavaScript needed.
In your theme’s function.php (or in a mini plugin, whatever) add this code:
add_action('wpcf7_mail_sent', 'ip_wpcf7_mail_sent'); function ip_wpcf7_mail_sent($wpcf7) { $on_sent_ok = $wpcf7->additional_setting('ip_on_sent_ok', false); if (is_array($on_sent_ok) && count($on_sent_ok) > 0) { wp_redirect(trim($on_sent_ok[0])); exit; } }
The ip_ is a prefix I’m using. You can change the identifiers if you know your stuff.
Then, in any CF7 form in the additional settings (at the very bottom), add this:
ip_on_sent_ok: https://example.com
Does the trick for me.
- The topic ‘[Plugin: Contact Form 7] How to: Redirect after submit’ is closed to new replies.