Skip to content

Instantly share code, notes, and snippets.

@KustomDeveloper
Created February 11, 2021 20:39
Show Gist options
  • Save KustomDeveloper/e5b00573d92f2b91f9b1c8ca6bac37cf to your computer and use it in GitHub Desktop.
Save KustomDeveloper/e5b00573d92f2b91f9b1c8ca6bac37cf to your computer and use it in GitHub Desktop.
Get data from contact form 7 submission for use in another function like for example: mailchimp, constant contact, etc.
function run_function_with_cf7_data($WPCF7_ContactForm) {
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
// $posted_data = $submission->get_posted_data();
$email = $submission->get_posted_data('your-email');
ob_start();
echo '<pre>';
print_r($email);
echo '<pre>';
$content = ob_get_clean();
wp_mail('kustomdesigner@gmail.com', 'Debug', $content);
}
}
add_action( 'wpcf7_mail_sent', 'run_function_with_cf7_data' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment