I was able to fix this compliance issue by simply changing this:
/**
* Redirect the user, after a successful email is sent
*/
function cf7_success_page_form_submitted( $contact_form ) {
$contact_form_id = $contact_form->id();
// Send us to a success page, if there is one
$success_page = get_post_meta( $contact_form_id, '_cf7_success_page_key', true );
if ( !empty($success_page) ) {
wp_redirect( get_permalink( $success_page ) );
die();
}
}
add_action( 'wpcf7_mail_sent', 'cf7_success_page_form_submitted' );
to:
/**
* Redirect the user after the submission is made & was confirmed to be successful
*/
function cf7_success_page_form_submitted( $contactform, $result ) {
// AJAX is enabled; use JavaScript to perform the redirect instead
if ( isset( $_POST['_wpcf7_is_ajax_call'] ) || ! isset( $result['status'] ) ) {
return;
}
// Set array of acceptible statuses/cases
$cases = (array) apply_filters( 'wpcf7_flamingo_submit_if',
array( 'mail_sent' ) );
// Reject the submission if it wasn't a valid status/case
if ( empty( $result['status'] )
|| ! in_array( $result['status'], $cases ) ) {
return;
}
// Otherwise, continue forward as it was a successful form submission
$contact_form_id = $contactform->id();
// Send user to a success page, if there is one
$success_page = get_post_meta( $contact_form_id, '_cf7_success_page_key', true );
if ( !empty($success_page) ) {
wp_redirect( get_permalink( $success_page ) );
die();
}
}
add_action( 'wpcf7_submit', 'cf7_success_page_form_submitted', 900, 2 );
within this plugin’s cf7-success-page-redirects.php file. This way, it doesn’t interrupt the remaining submission process (allowing other functions running in the wpcf7_submit
action to be completed first due to the really late 900
priority the cf7_success_page_form_submitted
function is now being given) while still redirecting when appropriate.
Please feel free to implement this fix, and I would love to see this patch officially implemented in a future version. Flamingo is the official form submission plugin for CF7 so this plugin should work with it, and I’m guessing this bug fix also improves compatibility with other plugins as well.
Let me know if you have any questions, and thanks for the great (soon-to-be really great) plugin!