I’ve got a website where I must alternate between two different “Send To” email address so that each address gets 50% of the submissions.
The only way that I can think to do this is to install the Flamingo plugin and check the submission ID that it creates to see if it is odd or even. This will help me to set the email address using the “wpcf7_before_send_mail” hook.
Is this a good way to achieve the requirement, or is there a better way to do this?
Will this code achieve what I need it to do…
`add_action( ‘wpcf7_before_send_mail’, ‘wpcf7_change_recipient’ );
function wpcf7_change_recipient($contact_form){
$submission = WPCF7_Submission::get_instance();
$recipient = "[email protected]" //set email address
if ($mail[_serial_number] % 2 == 0) {
$recipient = "[email protected]" //change email address if ID is even
}
if($recipient) {
$mail = $contact_form->prop( 'mail' );
$mail['recipient'] = $recipient;
$contact_form->set_properties(array('mail'=>$mail));
}
}`
WP Cork is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.