Hello GF Experts,
I’ve started using Gravity Forms and I’m trying to alternate the email address that notifications are sent to, so that each second emails is sent to an alternative address.
It’s for a sales team of 2 people and they want to divide the notifications 50/50 as each submission will be a sales lead.
I’ve tried the two following code snippets but neither will work as the are both setting the email to the same address for every submission.
Snippet Version 1 (sends to 1st email address every time)
add_filter( 'gform_pre_send_email', 'update_meta_before_send', 10, 2 );
function update_meta_before_send( $email, $notification ) {
$entry_id = $notification->entry_id;
if ( $entry_id % 2 == 0 ) {
$email['to'] = '1_email_address@mydomain.com';
} else {
$email['to'] = '2_email_address@mydomain.com'; // Original recipient
}
Snippet Version 2 (sends to 2nd email address every time)
add_filter( 'gform_pre_send_email', 'update_meta_before_send' );
function update_meta_before_send( $email ) {
$entry_id = $entry['entry_id'];
$email['to'] = '1_email_address@mydomain.com';
if ($entry_id %2 == 0){
$email['to'] = '2_email_address@mydomain.com';
}
return $email;
}
It seems that I’m not accessing the submission id correctly and I can’t figure out what I’m doing wrong. Any help would be appreciated.
Thanks in Advance,
Donal