Add or remove email addresses for email notifications.
Parameters: email (array), submitted values (array), $form_id (string)
Examples
Email Routing
add_filter('frm_to_email', 'custom_set_email_value', 20, 3);
function custom_set_email_value($emails, $values, $form_id){
if($form_id != 5) return $emails; //change 5 to the id of the form you would like to send
foreach($values as $value){
if($value->field_id != 65) continue; //change 65 to the id of the drop-down or radio select field
switch($value->meta_value){
case 'Ted': //replace Ted with your label for option 1 (this is case sensitive)
$emails[] = 'Ted@example.com';
break;
case 'Betty': //send to two email addresses
$emails[] = 'Betty@example.com';
$emails[] = 'Roger@example.com';
break;
case 'Michael':
$emails[] = 'Michael.@example.com';
break;
default:
$emails[] = 'default@example.com';
break;
}
}
return $emails;
}
Conditionally stop email
Stop the email if a field is set to draft by clearing out the list of email addresses the email is sending to.
Note: You need to create the field you will be using to track the entry status
add_filter('frm_to_email', 'stop_the_email', 20, 3 );
function stop_the_email($emails, $values, $form_id){
if(isset($_POST['item_meta'][30]) and $_POST['item_meta'][30] == 'draft') //change 30 to the id of the status field
return array();
else
return $emails;
}