$recipients = array_merge($recipients, mailusers_get_recipients_from_custom_meta_filters($send_filters, $exclude_id, MAILUSERS_ACCEPT_MASS_EMAIL_USER_META)); } if (class_exists(MAILUSERS_USER_GROUPS_CLASS) && !empty($send_ug)) { $recipients = array_merge($recipients, mailusers_get_recipients_from_user_groups($send_ug, $exclude_id, MAILUSERS_ACCEPT_MASS_EMAIL_USER_META)); } if (class_exists(MAILUSERS_USER_ACCESS_MANAGER_CLASS) && !empty($send_uam)) { $recipients = array_merge($recipients, mailusers_get_recipients_from_uam_group($send_uam, $exclude_id, MAILUSERS_ACCEPT_MASS_EMAIL_USER_META)); } if (class_exists(MAILUSERS_ITTHINX_GROUPS_CLASS) && !empty($send_groups)) { $recipients = array_merge($recipients, mailusers_get_recipients_from_itthinx_groups_group($send_groups, $exclude_id, MAILUSERS_ACCEPT_MASS_EMAIL_USER_META)); } if (class_exists(MAILUSERS_PMPRO_CLASS) && !empty($send_pmpro)) { $recipients = array_merge($recipients, mailusers_get_recipients_from_membership_levels($send_pmpro, $exclude_id, MAILUSERS_ACCEPT_MASS_EMAIL_USER_META)); } if (!empty($send_roles)) { $recipients = array_merge($recipients, mailusers_get_recipients_from_roles($send_roles, $exclude_id, MAILUSERS_ACCEPT_MASS_EMAIL_USER_META)); } if (empty($recipients)) { ?> <p><strong><?php _e('No recipients were found.', MAILUSERS_I18N_DOMAIN); ?> </strong></p> <?php } else { $num_sent = mailusers_send_mail($recipients, $subject, $mail_content, $mail_format, $from_name, $from_address); if (false === $num_sent) { print '<div class="error fade"><p> ' . __('There was a problem trying to send email to users.', MAILUSERS_I18N_DOMAIN) . '</p></div>'; } else { if (0 === $num_sent) { print '<div class="error fade"><p>' . __('No email has been sent to other users. This may be because no valid email addresses were found.', MAILUSERS_I18N_DOMAIN) . '</p></div>';
/** * Get the users based on roles * $meta_filter can be '', MAILUSERS_ACCEPT_NOTIFICATION_USER_META, or MAILUSERS_ACCEPT_MASS_EMAIL_USER_META * * Added support for editable_roles filter * @see https://wordpress.org/support/topic/mailusers_get_roles-function-to-use-the-core-get_editable_roles?replies=2#post-6513328 * */ function mailusers_get_roles($exclude_id = '', $meta_filter = '') { $roles = array(); $wp_roles = get_editable_roles(); foreach ($wp_roles as $key => $value) { $users_in_role = mailusers_get_recipients_from_roles(array($key), $exclude_id, $meta_filter); if (!empty($users_in_role)) { $roles[$key] = $value['name']; } } return $roles; }