Skip to content
Snippets Groups Projects
Commit 8b0b9d6e authored by Christian Elberfeld's avatar Christian Elberfeld
Browse files

fixed script

parent 894d8a91
No related branches found
No related tags found
No related merge requests found
......@@ -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);
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment