Contact Form 7 – Change Email Recipient


There is a shortcut method to change email recipient when contact form is submitted.

Add below code in functions.php. It will change email recipient for contact form 7.

// hook into wpcf7_before_send_mail
add_action( 'wpcf7_before_send_mail', function($contact_form){
 
// create new instance of WPCF7_Submission class
$submission = WPCF7_Submission::get_instance();
 
// email address you want to change
$toEmail = 'abc@xyz.com';
 
// set the email address to recipient
$mailProp = $contact_form->get_properties('mail');
$mailProp['mail']['recipient'] = $toEmail;
 
// update the form properties
$contact_form->set_properties(array('mail' => $mailProp['mail']));
 
});

8 responses to “Contact Form 7 – Change Email Recipient”

Leave a Reply

Your email address will not be published. Required fields are marked *