In Contact Form 7, if you hook into wpcf7_mail_sent
, then the $_POST
variable is empty, so you cannot use it to do stuff with it. You are too late. However, there is a way to get around this: you have to use Contact Form 7 built-in functions to get the posted data.
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$form_data = $submission->get_posted_data();
// now $form_data contains the form values,
// so you can do, for example $form_data['email'], instead of $_POST['email']
}else{
// we got nothing; something went wrong
}
That’s it.