Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/07/2022 08:32:51 PM (17 months ago)
Author:
imath
Message:

Eventually include inactive users in group's members count

When the Community Site Administrator decides to add an inactive user
as a member of a group from the Group's WP Admin screen, we need to
include them into the group's members count to remain consistent with the
fact:

  • an activity is created inside the group to inform this inactive user

joined the group

  • the group's members list is including this user.

Props dcavins, sjregan, espellcaste

Closes https://github.com/buddypress/buddypress/pull/33
Fixes #7614

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-group-member-query.php

    r13280 r13357  
    548548     *
    549549     * @since 10.3.0
     550     * @since 11.0.0 Include inactive users added by a community administrators to the group members count.
    550551     */
    551552    public function populate_extras() {
     
    555556
    556557        // Validate active users.
    557         $active_users    = array_filter( BP_Core_User::get_last_activity( $this->user_ids ) );
    558         $active_user_ids = array_keys( $active_users );
    559         $this->results   = array_intersect( $this->user_ids, $active_user_ids );
     558        if ( ! bp_current_user_can( 'bp_moderate' ) ) {
     559            $active_users    = array_filter( BP_Core_User::get_last_activity( $this->user_ids ) );
     560            $active_user_ids = array_keys( $active_users );
     561            $this->results   = array_intersect( $this->user_ids, $active_user_ids );
     562        } else {
     563            $this->results = $this->user_ids;
     564        }
    560565
    561566        // Set the total active users.
Note: See TracChangeset for help on using the changeset viewer.