/** * Get the users based on groups from the Paid Memberships Pro plugin * $meta_filter can be '', MAILUSERS_ACCEPT_NOTIFICATION_USER_META, or MAILUSERS_ACCEPT_MASS_EMAIL_USER_META */ function mailusers_get_membership_levels($exclude_id = '', $meta_filter = '') { global $wpdb; $pmp = array(); $groups = $wpdb->get_results("\n SELECT DISTINCT ml.id, ml.name FROM {$wpdb->prefix}pmpro_membership_levels ml"); foreach ($groups as $group) { $ids = mailusers_get_recipients_from_membership_levels($group->id, $exclude_id, $meta_filter); if (!empty($ids)) { $pmp[$group->id] = $group->name; } } return $pmp; }
// 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)) { ?> <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>';