bp_groups_disable_at_mention_forums_notification_for_non_public_groups( bool $send, array $usernames, int $user_id, int $forum_id )

Disable at-mention forum notifications for users who are not a member of the non-public group.

Description

Parameters

$send

(bool) (Required) Whether to send the notification.

$usernames

(array) (Required) Array of all usernames being notified.

$user_id

(int) (Required) ID of the user to be notified.

$forum_id

(int) (Required) ID of the forum.

Return

(bool)

Source

File: bp-groups/bp-groups-filters.php

function bp_groups_disable_at_mention_forums_notification_for_non_public_groups( $send, $usernames, $user_id, $forum_id ) {
	// Skip the check for administrators, who can get notifications from non-public groups.
	if ( bp_user_can( $user_id, 'bp_moderate' ) ) {
		return $send;
	}

	// Get group ID's for this forum
	$group_ids = bbp_get_forum_group_ids( $forum_id );

	// Bail if the post isn't associated with a group
	if ( empty( $group_ids ) ) {
		return $send;
	}

	// @todo Multiple group forums/forum groups
	$group_id = $group_ids[0];

	if ( ! bp_user_can( $user_id, 'groups_access_group', array( 'group_id' => $group_id ) ) ) {
		$send = false;
	}

	return $send;
}

Changelog

Changelog
Version Description
BuddyBoss 1.2.9 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.