Working just as expected
-
1) You creating group “NotifiedByEmail”, adding users to it.
2) Memorize ID of that group
3) Writing function:function getNotifiedUsersEmails() { // 2 - is the ID of group $group = new Groups_Group( 2 ); $users = $group->users; $emails = []; if (!$users) $users = []; foreach($users as $user) { $email = $user->user->data->user_email; $emails[] = $email; } return $emails; }4) And use it to send some notification emails only to users that are in a group:
$emails = getNotifiedUsersEmails(); foreach($emails as $email) { wp_mail( $email, $subject, $message, $headers ); }
The topic ‘Working just as expected’ is closed to new replies.