Пример #1
0
/**
 * Get the users based on groups from the User Groups plugin
 * $meta_filter can be '', MAILUSERS_ACCEPT_NOTIFICATION_USER_META, or MAILUSERS_ACCEPT_MASS_EMAIL_USER_META
 */
function mailusers_get_user_groups($exclude_id = '', $meta_filter = '')
{
    $ug = array();
    $terms = get_terms(MAILUSERS_USER_GROUPS_TAXONOMY, array('hide_empty' => true));
    foreach ($terms as $term) {
        $users_in_group = mailusers_get_recipients_from_user_groups(array($term->term_id), $exclude_id, $meta_filter);
        if (!empty($users_in_group)) {
            $ug[$term->term_id] = $term->name;
        }
    }
    return $ug;
}
             break;
         case MAILUSERS_PMPRO_PREFIX:
             $send_pmpro[] = $value;
             break;
         default:
             $send_roles[] = $value;
             break;
     }
 }
 //  Extract the recipinents from the various target sources
 $recipients = array();
 if (!empty($send_filters)) {
     $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)) {
     ?>