Skip to content

Commit e8c37e7

Browse files
committed
When checking to see if a user has access to opt out of a feature, if they have no role set but are a super admin, set their role to administrator
1 parent b33a8ac commit e8c37e7

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

includes/Classifai/Admin/UserProfile.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,19 @@ public function get_allowed_features( int $user_id ): array {
158158

159159
// Check if user has access to the feature by role.
160160
$allowed_roles = $settings['roles'] ?? [];
161-
if (
162-
$role_based_access_enabled &&
163-
! empty( $allowed_roles ) &&
164-
! empty( array_intersect( $user_roles, $allowed_roles ) )
165-
) {
166-
$allowed_features[ $feature_class::ID ] = $feature_class->get_label();
167-
continue;
161+
if ( $role_based_access_enabled ) {
162+
// For super admins that don't have a specific role on a site, treat them as admins.
163+
if ( is_multisite() && is_super_admin( $user_id ) && empty( $user_roles ) ) {
164+
$user_roles = [ 'administrator' ];
165+
}
166+
167+
if (
168+
! empty( $allowed_roles ) &&
169+
! empty( array_intersect( $user_roles, $allowed_roles ) )
170+
) {
171+
$allowed_features[ $feature_class::ID ] = $feature_class->get_label();
172+
continue;
173+
}
168174
}
169175

170176
// Check if user has access to the feature.

0 commit comments

Comments
 (0)