Skip to:
Content

BuddyPress.org

Changeset 10469


Ignore:
Timestamp:
01/25/2016 10:00:12 PM (9 years ago)
Author:
boonebgorges
Message:

Don't send notifications for activity in non-public group when mentioned user is not a member.

Props timeuser.
Fixes #6842.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-filters.php

    r10466 r10469  
    6565add_filter( 'bp_get_group_total_members',        'bp_core_number_format' );
    6666add_filter( 'bp_get_total_group_count_for_user', 'bp_core_number_format' );
     67
     68// Activity component integration.
     69add_filter( 'bp_activity_at_name_do_notifications', 'bp_groups_disable_at_mention_notification_for_non_public_groups', 10, 4 );
    6770
    6871/**
     
    285288}
    286289add_filter( 'bp_activity_maybe_load_mentions_scripts', 'bp_groups_maybe_load_mentions_scripts', 10, 2 );
     290
     291/**
     292 * Disable at-mention notifications for users who are not a member of the non-public group where the activity appears.
     293 *
     294 * @since 2.5.0
     295 *
     296 * @param bool                 $send      Whether to send the notification.
     297 * @param array                $usernames Array of all usernames being notified.
     298 * @param int                  $user_id   ID of the user to be notified.
     299 * @param BP_Activity_Activity $activity  Activity object.
     300 * @return bool
     301 */
     302function bp_groups_disable_at_mention_notification_for_non_public_groups( $send, $usernames, $user_id, BP_Activity_Activity $activity ) {
     303    if ( 'groups' === $activity->component ) {
     304        $group = groups_get_group( array( 'group_id' => $activity->item_id ) );
     305        if ( 'public' !== $group->status && ! groups_is_user_member( $user_id, $group->id ) ) {
     306            $send = false;
     307        }
     308    }
     309
     310    return $send;
     311}
Note: See TracChangeset for help on using the changeset viewer.