From b33a8aceaeb4575677c9e5e06cdbb3b308fdb758 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Sun, 4 Feb 2024 20:46:29 -0700 Subject: [PATCH] When checking to see if a user has access based on their role, if they have no roles set on a site but they are a super admin, set their role to administrator --- includes/Classifai/Features/Feature.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/Classifai/Features/Feature.php b/includes/Classifai/Features/Feature.php index 7f11af94e..2fad3ccad 100644 --- a/includes/Classifai/Features/Feature.php +++ b/includes/Classifai/Features/Feature.php @@ -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 ) ) ); }