Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ function map_user_roles( $user, array $attributes ) {
// Manage super admin flag
if ( is_sso_enabled_network_wide() ) {
if ( isset( $roles['network'] ) && in_array( 'superadmin', $roles['network'], true ) ) {
$roles = array_diff( $roles['network'], [ 'superadmin' ] );
// $roles = array_diff( $roles['network'], [ 'superadmin' ] );
// Had to remove this line. It removes the $roles['sites'] from the array. Cant have that as we have Super Admins who are also specific roles in specific sites.

if ( ! is_super_admin( $user->ID ) ) {
grant_super_admin( $user->ID );
Expand All @@ -496,8 +497,15 @@ function map_user_roles( $user, array $attributes ) {
$user->for_site( $site_id );
$user->set_role( reset( $site_roles ) );

foreach ( array_slice( $site_roles, 1 ) as $role ) {
$user->add_role( $role );
foreach ( $site_roles as $role ) {
// modified to include multiple roles per site. Our sites included multiple roles in an associative array.
if (is_array($role)) {
foreach ($role as $r) {
$user->add_role($r);
}
} else {
$user->add_role( $role );
}
}
}
} elseif ( ! isset( $roles['sites'] ) && isset( $roles['network'] ) ) {
Expand Down