Changeset 13357
- Timestamp:
- 11/07/2022 08:32:51 PM (22 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/classes/class-bp-group-member-query.php
r13280 r13357 548 548 * 549 549 * @since 10.3.0 550 * @since 11.0.0 Include inactive users added by a community administrators to the group members count. 550 551 */ 551 552 public function populate_extras() { … … 555 556 556 557 // 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 } 560 565 561 566 // Set the total active users. -
trunk/tests/phpunit/testcases/groups/functions.php
r13355 r13357 363 363 364 364 $this->assertEquals( 1, groups_get_total_member_count( $g1 ) ); 365 } 366 367 /** 368 * @group total_member_count 369 * @ticket BP7614 370 */ 371 public function test_total_member_count_groups_inactive_user_from_admin() { 372 $current_user = get_current_user_id(); 373 $u1 = self::factory()->user->create( 374 array( 375 'role' => 'administrator', 376 ) 377 ); 378 $u2 = wp_insert_user( array( 379 'user_pass' => 'barfoo', 380 'user_login' => 'barfoo', 381 'user_email' => 'barfoo@buddypress.org', 382 ) ); 383 384 $this->set_current_user( $u1 ); 385 $g1 = self::factory()->group->create(); 386 387 groups_join_group( $g1, $u2 ); 388 389 $this->assertEquals( 2, groups_get_total_member_count( $g1 ) ); 390 391 $this->set_current_user( $current_user ); 365 392 } 366 393
Note: See TracChangeset
for help on using the changeset viewer.