Skip to content

Commit

Permalink
Don't show 'Name' or 'Email' columns to non-faculty/staff on Dashboar…
Browse files Browse the repository at this point in the history
…d > Users.

See #3280.
  • Loading branch information
boonebgorges committed Dec 14, 2023
1 parent 1036d6e commit c706359
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions wp-content/plugins/wds-citytech/includes/group-blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,34 @@ function( $retval, $col, $user_id ) {
3
);

/**
* Remove columns that should not be visible to the current user.
*
* @param array $cols Columns.
* @return array
*/
add_filter(
'manage_users_columns',
function( $cols ) {
if ( is_super_admin() ) {
return $cols;
}

// 'faculty' and 'staff' can see all columns.
$user_type = openlab_get_user_member_type( get_current_user_id() );
if ( in_array( $user_type, [ 'faculty', 'staff' ], true ) ) {
return $cols;
}

// Remove the 'name' and 'email' columns.
unset( $cols['name'] );
unset( $cols['email'] );

return $cols;
},
100
);

/**
* Hide private comments even after the plugin is deactivated.
*
Expand Down

0 comments on commit c706359

Please sign in to comment.