File tree 2 files changed +18
-7
lines changed
2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -158,13 +158,19 @@ public function get_allowed_features( int $user_id ): array {
158
158
159
159
// Check if user has access to the feature by role.
160
160
$ 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
+ }
168
174
}
169
175
170
176
// Check if user has access to the feature.
Original file line number Diff line number Diff line change @@ -938,6 +938,11 @@ public function has_access(): bool {
938
938
* Checks if Role-based access is enabled and user role has access to the feature.
939
939
*/
940
940
if ( $ role_based_access_enabled ) {
941
+ // For super admins that don't have a specific role on a site, treat them as admins.
942
+ if ( is_multisite () && is_super_admin ( $ user_id ) && empty ( $ user_roles ) ) {
943
+ $ user_roles = [ 'administrator ' ];
944
+ }
945
+
941
946
$ access = ( ! empty ( $ feature_roles ) && ! empty ( array_intersect ( $ user_roles , $ feature_roles ) ) );
942
947
}
943
948
You can’t perform that action at this time.
0 commit comments