Skip to content

Commit

Permalink
Use 'view_private_members_of_group' cap rather than hardcoding checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
boonebgorges committed Jul 15, 2024
1 parent e49a334 commit 326c38c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion buddypress/groups/single/activity-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$group = groups_get_current_group();
$group_url = bp_get_group_permalink( $group );

if ( current_user_can( 'bp_moderate' ) || groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) {
if ( current_user_can( 'view_private_members_of_group', $group->id ) ) {
$group_private_members = [];
} else {
$group_private_members = openlab_get_private_members_of_group( $group->id );
Expand Down
2 changes: 1 addition & 1 deletion buddypress/groups/single/members.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$private_users = openlab_get_private_members_of_group( bp_get_current_group_id() );

// If user is not mod and there are private users, exclude them from the list
if ( ! current_user_can( 'bp_moderate' ) && ! empty( $private_users ) ) {
if ( ! current_user_can( 'view_private_members_of_group' ) && ! empty( $private_users ) ) {
$members_args['exclude'] = $private_users;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/group-funcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ function openlab_show_site_posts_and_comments() {

switch ( $site_type ) {
case 'local':
if ( current_user_can( 'bp_moderate' ) || groups_is_user_member( bp_loggedin_user_id(), $group_id ) ) {
if ( current_user_can( 'view_private_members_of_group', $group_id ) ) {
$group_private_members = [];
$post__not_in = [];
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,8 @@ function openlab_filter_subnav_members( $subnav_item ) {

// Get a member count for formatting.
$total_mem = (int) groups_get_groupmeta( bp_get_current_group_id(), 'total_member_count' );
if ( ! current_user_can( 'bp_moderate' ) ) {
$private_users = openlab_get_private_members_of_group( bp_get_current_group_id() );
if ( ! current_user_can( 'view_private_members_of_group' ) ) {
$private_users = openlab_get_private_members_of_group( bp_get_current_group_id(), false );
if ( $private_users ) {
$total_mem -= count( $private_users );
}
Expand Down

0 comments on commit 326c38c

Please sign in to comment.