Created
February 17, 2017 21:38
-
-
Save zeshanshani/714cf3a3fa57b206989634ac5443dba2 to your computer and use it in GitHub Desktop.
Redirect CF7 After Submission using PHP action hook.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Redirect CF7 After Submission | |
* | |
* Accepts 'custom_on_sent_ok' parameter in CF7 form additional settings. e.g., | |
* custom_on_sent_ok: http://example.com/thank-you | |
*/ | |
add_action( 'wpcf7_mail_sent', 'custom_redirect_cf7_form' ); | |
function custom_redirect_cf7_form( $wpcf7 ) { | |
$on_sent_ok = $wpcf7->additional_setting('custom_on_sent_ok', false); | |
if ( is_array( $on_sent_ok ) && count( $on_sent_ok ) > 0 ) { | |
wp_redirect( trim( $on_sent_ok[0] ) ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment