function groups_notification_group_updated($group_id)
{
    $group = groups_get_group(array('group_id' => $group_id));
    $subject = bp_get_email_subject(array('text' => __('Group Details Updated', 'buddypress')));
    $user_ids = BP_Groups_Member::get_group_member_ids($group->id);
    foreach ((array) $user_ids as $user_id) {
        if ('no' == bp_get_user_meta($user_id, 'notification_groups_group_updated', true)) {
            continue;
        }
        $ud = bp_core_get_core_userdata($user_id);
        // Set up and send the message
        $to = $ud->user_email;
        $group_link = bp_get_group_permalink($group);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($user_id) . $settings_slug . '/notifications/';
        $message = sprintf(__('Group details for the group "%1$s" were updated:

To view the group: %2$s

---------------------
', 'buddypress'), $group->name, $group_link);
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        /* Send the message */
        $to = apply_filters('groups_notification_group_updated_to', $to);
        $subject = apply_filters_ref_array('groups_notification_group_updated_subject', array($subject, &$group));
        $message = apply_filters_ref_array('groups_notification_group_updated_message', array($message, &$group, $group_link, $settings_link));
        wp_mail($to, $subject, $message);
        unset($message, $to);
    }
    do_action('bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id);
}
function groups_notification_group_updated($group_id)
{
    global $bp;
    $group = new BP_Groups_Group($group_id);
    $sitename = wp_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
    $subject = '[' . $sitename . '] ' . __('Group Details Updated', 'buddypress');
    $user_ids = BP_Groups_Member::get_group_member_ids($group->id);
    foreach ((array) $user_ids as $user_id) {
        if ('no' == bp_get_user_meta($user_id, 'notification_groups_group_updated', true)) {
            continue;
        }
        $ud = bp_core_get_core_userdata($user_id);
        // Set up and send the message
        $to = $ud->user_email;
        $group_link = site_url(bp_get_groups_root_slug() . '/' . $group->slug);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($user_id) . $settings_slug . '/notifications/';
        $message = sprintf(__('Group details for the group "%1$s" were updated:

To view the group: %2$s

---------------------
', 'buddypress'), $group->name, $group_link);
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        /* Send the message */
        $to = apply_filters('groups_notification_group_updated_to', $to);
        $subject = apply_filters_ref_array('groups_notification_group_updated_subject', array($subject, &$group));
        $message = apply_filters_ref_array('groups_notification_group_updated_message', array($message, &$group, $group_link, $settings_link));
        wp_mail($to, $subject, $message);
        unset($message, $to);
    }
    do_action('bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id);
}
Example #3
0
 public function user_member_ids()
 {
     if (is_null($this->_user_members)) {
         if (self::owner_type_group == $this->owner_type) {
             $this->_user_members = (array) BP_Groups_Member::get_group_member_ids($this->owner_id);
         } else {
             $this->_user_members = array($this->owner_id);
         }
     }
     return $this->_user_members;
 }
/**
 * Notify all group members when a group is updated.
 *
 * @since BuddyPress (1.0.0)
 *
 * @param int $group_id ID of the group.
 * @param BP_Groups_Group $old_group Group before new details were saved.
 */
function groups_notification_group_updated($group_id = 0, $old_group = null)
{
    $group = groups_get_group(array('group_id' => $group_id));
    if ($old_group instanceof BP_Groups_Group) {
        $changed = array();
        if ($group->name !== $old_group->name) {
            $changed[] = sprintf(_x('* Name changed from "%s" to "%s"', 'Group update email text', 'buddypress'), esc_html($old_group->name), esc_html($group->name));
        }
        if ($group->description !== $old_group->description) {
            $changed[] = sprintf(_x('* Description changed from "%s" to "%s"', 'Group update email text', 'buddypress'), esc_html($old_group->description), esc_html($group->description));
        }
    }
    /**
     * Filters the bullet points listing updated items in the email notification after a group is updated.
     *
     * @since BuddyPress (2.2.0)
     *
     * @param array $changed Array of bullet points.
     */
    $changed = apply_filters('groups_notification_group_update_updated_items', $changed);
    $changed_text = '';
    if (!empty($changed)) {
        $changed_text = "\n\n" . implode("\n", $changed);
    }
    $subject = bp_get_email_subject(array('text' => __('Group Details Updated', 'buddypress')));
    $user_ids = BP_Groups_Member::get_group_member_ids($group->id);
    foreach ((array) $user_ids as $user_id) {
        // Continue if member opted out of receiving this email
        if ('no' === bp_get_user_meta($user_id, 'notification_groups_group_updated', true)) {
            continue;
        }
        $ud = bp_core_get_core_userdata($user_id);
        // Set up and send the message
        $to = $ud->user_email;
        $group_link = bp_get_group_permalink($group);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($user_id) . $settings_slug . '/notifications/';
        $message = sprintf(__('Group details for the group "%1$s" were updated: %2$s

To view the group: %3$s

---------------------
', 'buddypress'), $group->name, $changed_text, $group_link);
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        /* Send the message */
        $to = apply_filters('groups_notification_group_updated_to', $to);
        $subject = apply_filters_ref_array('groups_notification_group_updated_subject', array($subject, &$group));
        $message = apply_filters_ref_array('groups_notification_group_updated_message', array($message, &$group, $group_link, $settings_link));
        wp_mail($to, $subject, $message);
        unset($message, $to);
    }
    do_action('bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id);
}
/**
 * Notify all group members when a group is updated.
 *
 * @since 1.0.0
 *
 * @param int                  $group_id  ID of the group.
 * @param BP_Groups_Group|null $old_group Group before new details were saved.
 */
function groups_notification_group_updated($group_id = 0, $old_group = null)
{
    $group = groups_get_group($group_id);
    if ($old_group instanceof BP_Groups_Group) {
        $changed = array();
        if ($group->name !== $old_group->name) {
            $changed[] = sprintf(_x('* Name changed from "%s" to "%s".', 'Group update email text', 'buddypress'), esc_html($old_group->name), esc_html($group->name));
        }
        if ($group->description !== $old_group->description) {
            $changed[] = sprintf(_x('* Description changed from "%s" to "%s".', 'Group update email text', 'buddypress'), esc_html($old_group->description), esc_html($group->description));
        }
    }
    /**
     * Filters the bullet points listing updated items in the email notification after a group is updated.
     *
     * @since 2.2.0
     *
     * @param array $changed Array of bullet points.
     */
    $changed = apply_filters('groups_notification_group_update_updated_items', $changed);
    $changed_text = '';
    if (!empty($changed)) {
        $changed_text = implode("\n", $changed);
    }
    $user_ids = BP_Groups_Member::get_group_member_ids($group->id);
    foreach ((array) $user_ids as $user_id) {
        // Continue if member opted out of receiving this email.
        if ('no' === bp_get_user_meta($user_id, 'notification_groups_group_updated', true)) {
            continue;
        }
        $unsubscribe_args = array('user_id' => $user_id, 'notification_type' => 'groups-details-updated');
        $args = array('tokens' => array('changed_text' => $changed_text, 'group' => $group, 'group.id' => $group_id, 'group.url' => esc_url(bp_get_group_permalink($group)), 'group.name' => $group->name, 'unsubscribe' => esc_url(bp_email_get_unsubscribe_link($unsubscribe_args))));
        bp_send_email('groups-details-updated', (int) $user_id, $args);
    }
    /**
     * Fires after the notification is sent that a group has been updated.
     *
     * See https://buddypress.trac.wordpress.org/ticket/3644 for blank message parameter.
     *
     * @since 1.5.0
     * @since 2.5.0 $subject has been unset and is deprecated.
     *
     * @param array  $user_ids Array of user IDs to notify about the update.
     * @param string $subject  Deprecated in 2.5; now an empty string.
     * @param string $value    Empty string preventing PHP error.
     * @param int    $group_id ID of the group that was updated.
     */
    do_action('bp_groups_sent_updated_email', $user_ids, '', '', $group_id);
}
function groups_notification_group_updated( $group_id ) {
	global $bp;

	$group    = new BP_Groups_Group( $group_id );
	$sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
	$subject  = '[' . $sitename . '] ' . __( 'Group Details Updated', 'buddypress' );

	$user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
	foreach ( (array)$user_ids as $user_id ) {
		if ( 'no' == get_user_meta( $user_id, 'notification_groups_group_updated', true ) ) continue;

		$ud = bp_core_get_core_userdata( $user_id );

		// Set up and send the message
		$to = $ud->user_email;

		$group_link = site_url( $bp->groups->slug . '/' . $group->slug );
		$settings_link = bp_core_get_user_domain( $user_id ) .  BP_SETTINGS_SLUG . '/notifications/';

		$message = sprintf( __(
'Group details for the group "%s" were updated:

To view the group: %s

---------------------
', 'buddypress' ), $group->name, $group_link );

		$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );

		/* Send the message */
		$to = apply_filters( 'groups_notification_group_updated_to', $to );
		$subject = apply_filters( 'groups_notification_group_updated_subject', $subject, &$group );
		$message = apply_filters( 'groups_notification_group_updated_message', $message, &$group, $group_link );

		wp_mail( $to, $subject, $message );

		unset( $message, $to );
	}
}
 function delete()
 {
     global $wpdb, $bp;
     // Delete groupmeta for the group
     groups_delete_groupmeta($this->id);
     // Fetch the user IDs of all the members of the group
     $user_ids = BP_Groups_Member::get_group_member_ids($this->id);
     $user_id_str = implode(',', (array) $user_ids);
     // Modify group count usermeta for members
     $wpdb->query("UPDATE {$wpdb->usermeta} SET meta_value = meta_value - 1 WHERE meta_key = 'total_group_count' AND user_id IN ( {$user_id_str} )");
     // Now delete all group member entries
     BP_Groups_Member::delete_all($this->id);
     do_action_ref_array('bp_groups_delete_group', array(&$this, $user_ids));
     wp_cache_delete('bp_groups_group_' . $this->id, 'bp');
     // Finally remove the group entry from the DB
     if (!$wpdb->query($wpdb->prepare("DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id))) {
         return false;
     }
     return true;
 }
Example #8
0
/**
 * bp_group_documents_email_notificiation()
 *
 * This function will send email notifications to users on successful document upload.
 * For each group memeber, it will check to see the users notification settings first, 
 * if the user has the notifications turned on, they will be sent a formatted email notification. 
 */
function bp_group_documents_email_notification($document)
{
    global $bp;
    $user_name = bp_core_get_userlink($bp->loggedin_user->id, true);
    $user_profile_link = bp_core_get_userlink($bp->loggedin_user->id, false, true);
    $group_name = $bp->groups->current_group->name;
    $group_link = bp_get_group_permalink($bp->groups->current_group);
    $document_name = $document->name;
    $document_link = $document->get_url();
    $subject = '[' . get_blog_option(1, 'blogname') . '] ' . sprintf(__('A document was uploaded to %s', 'bp-group-documents'), $bp->groups->current_group->name);
    //these will be all the emails getting the update
    //'user_id' => 'user_email
    $emails = array();
    //first get the admin & moderator emails
    if (count($bp->groups->current_group->admins)) {
        foreach ($bp->groups->current_group->admins as $user) {
            if ('no' == get_user_meta($user->user_id, 'notification_group_documents_upload_mod')) {
                continue;
            }
            $emails[$user->user_id] = $user->user_email;
        }
    }
    if (count($bp->groups->current_group->mods)) {
        foreach ($bp->groups->current_group->mods as $user) {
            if ('no' == get_user_meta($user->user_id, 'notification_group_documents_upload_mod')) {
                continue;
            }
            if (!in_array($user->user_email, $emails)) {
                $emails[$user->user_id] = $user->user_email;
            }
        }
    }
    //now get all member emails, checking to make sure not to send any emails twice
    $user_ids = BP_Groups_Member::get_group_member_ids($bp->groups->current_group->id);
    foreach ((array) $user_ids as $user_id) {
        if ('no' == get_user_meta($user_id, 'notification_group_documents_upload_member')) {
            continue;
        }
        $ud = bp_core_get_core_userdata($user_id);
        if (!in_array($ud->user_email, $emails)) {
            $emails[$user_id] = $ud->user_email;
        }
    }
    foreach ($emails as $current_id => $current_email) {
        $message = sprintf(__('%s uploaded a new file: %s to the group: %s.

To see %s\'s profile: %s

To see the group %s\'s homepage: %s

To download the new document directly: %s

------------------------
', 'bp-group-documents'), $user_name, $document_name, $group_name, $user_name, $user_profile_link, $group_name, $group_link, $document_link);
        $settings_link = bp_core_get_user_domain($current_id) . $bp->settings->slug . '/notifications/';
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'bp-group-documents'), $settings_link);
        // Set up and send the message
        $to = $current_email;
        wp_mail($to, $subject, $message);
        unset($to, $message);
    }
    //end foreach
}
/**
 * Notify all group members when a group is updated.
 *
 * @since 1.0.0
 *
 * @param int                  $group_id  ID of the group.
 * @param BP_Groups_Group|null $old_group Group before new details were saved.
 */
function groups_notification_group_updated($group_id = 0, $old_group = null)
{
    $group = groups_get_group(array('group_id' => $group_id));
    if ($old_group instanceof BP_Groups_Group) {
        $changed = array();
        if ($group->name !== $old_group->name) {
            $changed[] = sprintf(_x('* Name changed from "%s" to "%s"', 'Group update email text', 'buddypress'), esc_html($old_group->name), esc_html($group->name));
        }
        if ($group->description !== $old_group->description) {
            $changed[] = sprintf(_x('* Description changed from "%s" to "%s"', 'Group update email text', 'buddypress'), esc_html($old_group->description), esc_html($group->description));
        }
    }
    /**
     * Filters the bullet points listing updated items in the email notification after a group is updated.
     *
     * @since 2.2.0
     *
     * @param array $changed Array of bullet points.
     */
    $changed = apply_filters('groups_notification_group_update_updated_items', $changed);
    $changed_text = '';
    if (!empty($changed)) {
        $changed_text = "\n\n" . implode("\n", $changed);
    }
    $subject = bp_get_email_subject(array('text' => __('Group Details Updated', 'buddypress')));
    $user_ids = BP_Groups_Member::get_group_member_ids($group->id);
    foreach ((array) $user_ids as $user_id) {
        // Continue if member opted out of receiving this email.
        if ('no' === bp_get_user_meta($user_id, 'notification_groups_group_updated', true)) {
            continue;
        }
        $ud = bp_core_get_core_userdata($user_id);
        // Set up and send the message.
        $to = $ud->user_email;
        $group_link = bp_get_group_permalink($group);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($user_id) . $settings_slug . '/notifications/';
        $message = sprintf(__('Group details for the group "%1$s" were updated: %2$s

To view the group: %3$s

---------------------
', 'buddypress'), $group->name, $changed_text, $group_link);
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        /**
         * Filters the user email that the group update notification will be sent to.
         *
         * @since 1.2.0
         *
         * @param string $to User email the notification is being sent to.
         */
        $to = apply_filters('groups_notification_group_updated_to', $to);
        /**
         * Filters the group update notification subject that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string          $subject Email notification subject text.
         * @param BP_Groups_Group $group   Object holding the current group instance. Passed by reference.
         */
        $subject = apply_filters_ref_array('groups_notification_group_updated_subject', array($subject, &$group));
        /**
         * Filters the group update notification message that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string          $message       Email notification message text.
         * @param BP_Groups_Group $group         Object holding the current group instance. Passed by reference.
         * @param string          $group_link    URL permalink to the group that was updated.
         * @param string          $settings_link URL permalink for the user's notification settings area.
         */
        $message = apply_filters_ref_array('groups_notification_group_updated_message', array($message, &$group, $group_link, $settings_link));
        wp_mail($to, $subject, $message);
        unset($message, $to);
    }
    /**
     * Fires after the notification is sent that a group has been updated.
     *
     * See https://buddypress.trac.wordpress.org/ticket/3644 for blank message parameter.
     *
     * @since 1.5.0
     *
     * @param array  $user_ids Array of user IDs to notify about the update.
     * @param string $subject  Email notification subject text.
     * @param string $value    Empty string preventing PHP error.
     * @param int    $group_id ID of the group that was updated.
     */
    do_action('bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id);
}
 /**
  * Delete the current group.
  *
  * @return bool True on success, false on failure.
  */
 public function delete()
 {
     global $wpdb;
     // Delete groupmeta for the group.
     groups_delete_groupmeta($this->id);
     // Fetch the user IDs of all the members of the group.
     $user_ids = BP_Groups_Member::get_group_member_ids($this->id);
     $user_id_str = esc_sql(implode(',', wp_parse_id_list($user_ids)));
     // Modify group count usermeta for members.
     $wpdb->query("UPDATE {$wpdb->usermeta} SET meta_value = meta_value - 1 WHERE meta_key = 'total_group_count' AND user_id IN ( {$user_id_str} )");
     // Now delete all group member entries.
     BP_Groups_Member::delete_all($this->id);
     /**
      * Fires before the deletion of a group.
      *
      * @since 1.2.0
      *
      * @param BP_Groups_Group $this     Current instance of the group item being deleted. Passed by reference.
      * @param array           $user_ids Array of user IDs that were members of the group.
      */
     do_action_ref_array('bp_groups_delete_group', array(&$this, $user_ids));
     wp_cache_delete($this->id, 'bp_groups');
     $bp = buddypress();
     // Finally remove the group entry from the DB.
     if (!$wpdb->query($wpdb->prepare("DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id))) {
         return false;
     }
     return true;
 }
Example #11
0
	function delete() {
		global $wpdb, $bp;

		/* Delete groupmeta for the group */
		groups_delete_groupmeta( $this->id );

		/* Fetch the user IDs of all the members of the group */
		$user_ids = BP_Groups_Member::get_group_member_ids( $this->id );
		$user_ids = implode( ',', (array)$user_ids );

		/* Modify group count usermeta for members */
		$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->usermeta} SET meta_value = meta_value - 1 WHERE meta_key = 'total_group_count' AND user_id IN ( {$user_ids} )" ) );

		/* Now delete all group member entries */
		BP_Groups_Member::delete_all( $this->id );

		do_action( 'bp_groups_delete_group', $this );

		// Finally remove the group entry from the DB
		if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) )
			return false;

		return true;
	}
function ass_admin_notice()
{
    if (bp_is_groups_component() && bp_is_current_action('admin') && bp_is_action_variable('notifications', 0)) {
        // Make sure the user is an admin
        if (!groups_is_user_admin(bp_loggedin_user_id(), bp_get_current_group_id()) && !is_super_admin()) {
            return;
        }
        if (get_option('ass-admin-can-send-email') == 'no') {
            return;
        }
        // make sure the correct form variables are here
        if (!isset($_POST['ass_admin_notice_send'])) {
            return;
        }
        if (empty($_POST['ass_admin_notice'])) {
            bp_core_add_message(__('The email notice was sent not sent. Please enter email content.', 'bp-ass'), 'error');
        } else {
            $group = groups_get_current_group();
            $group_id = $group->id;
            $group_name = bp_get_current_group_name();
            $group_link = bp_get_group_permalink($group);
            if ($group->status != 'public') {
                $group_link = ass_get_login_redirect_url($group_link, 'admin_notice');
            }
            $blogname = '[' . get_blog_option(BP_ROOT_BLOG, 'blogname') . ']';
            $subject = $_POST['ass_admin_notice_subject'];
            $subject .= __(' - sent from the group ', 'bp-ass') . $group_name . ' ' . $blogname;
            $subject = apply_filters('ass_admin_notice_subject', $subject, $_POST['ass_admin_notice_subject'], $group_name, $blogname);
            $subject = ass_clean_subject($subject, false);
            $notice = apply_filters('ass_admin_notice_message', $_POST['ass_admin_notice']);
            $notice = ass_clean_content($notice);
            $message = sprintf(__('This is a notice from the group \'%s\':

"%s"


To view this group log in and follow the link below:
%s

---------------------
', 'bp-ass'), $group_name, $notice, $group_link);
            $message .= __('Please note: admin notices are sent to everyone in the group and cannot be disabled.
If you feel this service is being misused please speak to the website administrator.', 'bp-ass');
            $user_ids = BP_Groups_Member::get_group_member_ids($group_id);
            // allow others to perform an action when this type of email is sent, like adding to the activity feed
            do_action('ass_admin_notice', $group_id, $subject, $notice);
            // cycle through all group members
            foreach ((array) $user_ids as $user_id) {
                $user = bp_core_get_core_userdata($user_id);
                // Get the details for the user
                if ($user->user_email) {
                    wp_mail($user->user_email, $subject, $message);
                }
                // Send the email
                //echo '<br>Email: ' . $user->user_email;
            }
            bp_core_add_message(__('The email notice was sent successfully.', 'bp-ass'));
            //echo '<p>Subject: ' . $subject;
            //echo '<pre>'; print_r( $message ); echo '</pre>';
        }
        bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/notifications/');
    }
}
Example #13
0
function bp_gtm_search_gmembers($search_term, $limit, $group_id, $role)
{
    global $bp, $wpdb;
    if ($role == 'admins') {
        $allmembers = BP_Groups_Member::get_group_administrator_ids($group_id);
    } elseif ($role == 'mods') {
        $allmembers = BP_Groups_Member::get_group_moderator_ids($group_id);
    } elseif ($role == 'members') {
        $allmembers = BP_Groups_Member::get_group_member_ids($group_id);
    }
    /* Fetch the user's full name */
    //    if (function_exists('xprofile_install')) {
    /* Ensure xprofile globals are set */
    if (!defined('BP_XPROFILE_FULLNAME_FIELD_NAME')) {
        xprofile_setup_globals();
    }
    $allmembers = $wpdb->escape(implode(',', (array) $allmembers));
    $members = $wpdb->get_results($wpdb->prepare("\n            SELECT `user_id` as `id` FROM {$bp->profile->table_name_data}\n            WHERE `field_id` = 1 AND `user_id` IN ( {$allmembers} ) AND `value` LIKE '%%{$search_term}%%'\n            LIMIT %d\n            ", $limit));
    return $members;
}
Example #14
0
/**
 * Process a group activity comment.
 *
 * @since 1.0.0
 *
 * @param object $activity The activity item being saved.
 */
function crowdmentions_activity_after_save_group_activity_comment($activity)
{
    if ($activity->type !== 'activity_comment') {
        return;
    }
    $root_activity = new BP_Activity_Activity($activity->item_id);
    if ($root_activity->component !== 'groups') {
        return;
    }
    // Find mentions in the activity item's content.
    $mentions = crowdmentions_find_mentions($activity->content);
    foreach ((array) array_values($mentions) as $mention) {
        if (!bp_is_active('groups') && $mention === 'group') {
            continue;
        }
        if (!bp_is_active('groups') && $mention === 'moderators') {
            continue;
        }
        if (!bp_is_active('groups') && $mention === 'administrators') {
            continue;
        }
        if (!bp_is_active('friends') && $mention === 'friends') {
            continue;
        }
        switch ($mention) {
            case 'group':
                $args = array('user_ids' => BP_Groups_Member::get_group_member_ids($root_activity->item_id), 'user_id' => $activity->user_id, 'item_id' => $activity->id, 'secondary_item_id' => $root_activity->item_id, 'component_action' => 'mention_group_' . $activity->id);
                break;
            case 'moderators':
                $user_ids = [];
                $mods = BP_Groups_Member::get_group_moderator_ids($root_activity->item_id);
                // Get an array of moderator IDs.
                foreach ((array) $mods as $mod) {
                    $user_ids[] = $mod->user_id;
                }
                $args = array('user_ids' => $user_ids, 'user_id' => $activity->user_id, 'item_id' => $activity->id, 'secondary_item_id' => $root_activity->item_id, 'component_action' => 'mention_moderators_' . $activity->id);
                break;
            case 'administrators':
                $user_ids = [];
                $admins = BP_Groups_Member::get_group_administrator_ids($root_activity->item_id);
                // Get an array of administrator IDs.
                foreach ((array) $admins as $admin) {
                    $user_ids[] = $admin->user_id;
                }
                $args = array('user_ids' => $user_ids, 'user_id' => $activity->user_id, 'item_id' => $activity->id, 'secondary_item_id' => $root_activity->item_id, 'component_action' => 'mention_administrators_' . $activity->id);
                break;
            case 'friends':
                $friend_ids = BP_Friends_Friendship::get_friend_user_ids($activity->user_id, false, false);
                $args = array('user_ids' => array_intersect(BP_Groups_Member::get_group_member_ids($root_activity->item_id), $friend_ids), 'user_id' => $activity->user_id, 'item_id' => $activity->id, 'secondary_item_id' => $root_activity->item_id, 'component_action' => 'mention_friends_' . $activity->id);
                break;
            default:
                // Skip to the next iteration.
                continue 2;
        }
        // Send notifications.
        crowdmentions_send_notifications($args);
    }
}