Skip to content

Commit

Permalink
Support multisite super administrator user role
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenjacoby committed Feb 18, 2021
1 parent f333b6a commit 2285826
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Intervention.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ protected function initRoleFromConfigFile($group, $class, $str)
$wp_roles = new \WP_Roles();
$current_user = wp_get_current_user();

/**
* Support multisite
*
* WordPress passes `$current_user->roles` as an empty array
* when the user is a super-administrator on a multisite setup,
* so we manually add 'administrator' to `$current_user->roles`
*/
if (is_multisite() && empty($current_user->roles)) {
$current_user->roles = ['administrator'];
}

$init = $group->filter(function ($v, $k) use ($str, $wp_roles, $current_user) {
$key = Str::explode('.', $k);
$roles = Str::explode('|', $key->shift());
Expand Down

0 comments on commit 2285826

Please sign in to comment.