Dear,
This is a follow-up of ticket:
https://toolset.com/forums/topic/send-email-notification-to-all-users-of-a-certain-role/
in:
add_filter('cred_notification_recipients', 'send_subscribed_users_func', 10, 4);
function send_subscribed_users_func($recipients, $notification, $form_id, $post_id){
if ( 29015 == $form_id){
$args = array('meta_key'=> 'wpcf-notification-offer-program', 'meta_value' => 1, 'fields' => array( 'display_name', 'user_email') );
$users = get_users( $args );
foreach($users as $user){
$recipients[] = array('to' => 'to', 'address' => $user->user_email, 'display_name' => $user->display_name );
}
etc.
This works perfectly.
Now I want to end this email with "bcc" option. I tried adding to the recipients one "to" (my own email) and the other users in bcc, but the email went only to the "to", not the emails in bcc. For example, in the code below, email goes only to first email:
//$recipients[] = array('to' => 'to', 'address' => "na76@gmail.com", 'display_name' => "nabil" );
//$recipients[] = array('Bcc' => 'Bcc', 'address' => "nabil@mail.com", 'display_name' => "bcc" );
Thank you for helping
Nabil
Hello,
You can try this, modify this line from:
$recipients[] = array('to' => 'to', 'address' => $user->user_email, 'display_name' => $user->display_name );
To:
$recipients[] = array('to' => 'bcc', 'address' => $user->user_email, 'display_name' => $user->display_name );
See our document:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
click link "Usage examples", there is a similar example codes as your case.
My issue is resolved now. Thank you!