April 28, 2020
Contact Form 7: Overwrite/Manipulate Posted Data Before Sending Email
Copy this code to your theme’s functions.php to manipulate the posted data by the visitor, update, add or remove fields and such.
There’s a lot that you can do with it!
add_filter( 'wpcf7_posted_data', 'compform_file_url', 10, 1 ); function compform_file_url($posted_data){ // Add / update field with value $posted_data['new_field'] = 'new value'; // Check if 'your-email' is [email protected] if ($posted_data['your-email']=='[email protected]') { //Remove the email field from the posted data unset($posted_data['your-email']); } return $posted_data; }