diff --git a/testserver/docker_wordpress/Documentation.md b/testserver/docker_wordpress/Documentation.md index b636e64c97497e18676ee978b35211e9a84d000a..aec4e8677134f074712c1b42ba613e474842581f 100644 --- a/testserver/docker_wordpress/Documentation.md +++ b/testserver/docker_wordpress/Documentation.md @@ -68,27 +68,31 @@ Benutzer, mit der Gruppe 'wordpress_admin' in uddf erhalten Administrator-Berech Alle anderen Benutzer erhalten Editor-Berechtigungen. ``` -add_action('openid-connect-generic-update-user-using-current-claim', function( $user, $user_claim) { - - // Based on some data in the user_claim, modify the user. - foreach($user_claim as $key => $value) { - error_log('Openid Role mapping: User claim: ' . $key . ', Value: ' . $value); - } - - if ( array_key_exists( 'groups', $user_claim ) ) { - - error_log('Openid Role mapping: Groups: ' . implode(',',$user_claim['groups'])); - - if ( in_array('wordpress_admin', $user_claim['groups'] )) { - - error_log('Openid Role mapping: Set role: Administrator'); - $user->set_role( 'administrator' ); - } - else { - - error_log('Openid Role mapping: Set role: Editor'); - $user->set_role( 'editor' ); - } +add_action('openid-connect-generic-update-user-using-current-claim', function($user, $user_claim) { + + // Log all user claims safely + foreach($user_claim as $key => $value) { + $valueToLog = is_array($value) ? json_encode($value) : $value; + error_log('Openid Role mapping: User claim: ' . $key . ', Value: ' . $valueToLog); + } + + if (array_key_exists('groups', $user_claim)) { + // Ensure groups is an array before working with it + if (is_array($user_claim['groups'])) { + error_log('Openid Role mapping: Groups: ' . implode(',', $user_claim['groups'])); + + if (in_array('wordpress_admin', $user_claim['groups'])) { + error_log('Openid Role mapping: Set role: Administrator'); + $user->set_role('administrator'); + } else { + error_log('Openid Role mapping: Set role: Editor'); + $user->set_role('editor'); + } + } else { + // If groups is not an array, log its actual format + error_log('Openid Role mapping: Groups is not an array: ' . gettype($user_claim['groups'])); + error_log('Openid Role mapping: Groups value: ' . json_encode($user_claim['groups'])); + } } }, 10, 2); ```