Skip to content

Commit

Permalink
When checking to see if a user has access based on their role, if the…
Browse files Browse the repository at this point in the history
…y have no roles set on a site but they are a super admin, set their role to administrator
  • Loading branch information
dkotter committed Feb 5, 2024
1 parent 0180001 commit b33a8ac
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions includes/Classifai/Features/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,11 @@ public function has_access(): bool {
* Checks if Role-based access is enabled and user role has access to the feature.
*/
if ( $role_based_access_enabled ) {
// For super admins that don't have a specific role on a site, treat them as admins.
if ( is_multisite() && is_super_admin( $user_id ) && empty( $user_roles ) ) {
$user_roles = [ 'administrator' ];
}

$access = ( ! empty( $feature_roles ) && ! empty( array_intersect( $user_roles, $feature_roles ) ) );
}

Expand Down

0 comments on commit b33a8ac

Please sign in to comment.