diff --git a/public/main/inc/lib/extra_field_value.lib.php b/public/main/inc/lib/extra_field_value.lib.php index 98d98d6bca..b00883c676 100644 --- a/public/main/inc/lib/extra_field_value.lib.php +++ b/public/main/inc/lib/extra_field_value.lib.php @@ -79,7 +79,7 @@ class ExtraFieldValue extends Model * In order to save this function needs a item_id (user id, course id, etc) * This function is used with $extraField->addElements(). * - * @param array $params array for the insertion into the *_field_values table + * @param array $params array for the insertion into the *_field_values table (each label must be prefixed by 'extra_') * @param bool $onlySubmittedFields Only save parameters in the $param array * @param bool $showQuery * @param array $saveOnlyThisFields diff --git a/public/main/inc/lib/usermanager.lib.php b/public/main/inc/lib/usermanager.lib.php index 37877fc9ae..723e6bad75 100644 --- a/public/main/inc/lib/usermanager.lib.php +++ b/public/main/inc/lib/usermanager.lib.php @@ -130,7 +130,7 @@ class UserManager * @param string $expirationDate Account expiration date (optional, defaults to null) * @param int $active Whether the account is enabled or disabled by default * @param int $hr_dept_id The department of HR in which the user is registered (defaults to 0) - * @param array $extra Extra fields + * @param array $extra Extra fields (labels must be prefixed by "extra_") * @param string $encrypt_method Used if password is given encrypted. Set to an empty string by default * @param bool $send_mail * @param bool $isAdmin @@ -377,8 +377,18 @@ class UserManager if (is_array($extra) && count($extra) > 0) { $extra['item_id'] = $userId; - $courseFieldValue = new ExtraFieldValue('user'); - $courseFieldValue->saveFieldValues($extra); + $userFieldValue = new ExtraFieldValue('user'); + /* Force saving of extra fields (otherwise, if the current + user is not admin, fields not visible to the user - most + of them - are just ignored) */ + $userFieldValue->saveFieldValues( + $extra, + true, + null, + null, + null, + true + ); } else { // Create notify settings by default self::update_extra_field_value( diff --git a/public/plugin/azure_active_directory/src/callback.php b/public/plugin/azure_active_directory/src/callback.php index 481ffe1d6a..5e0c975c44 100644 --- a/public/plugin/azure_active_directory/src/callback.php +++ b/public/plugin/azure_active_directory/src/callback.php @@ -94,8 +94,8 @@ try { ($me['accountEnabled'] ? 1 : 0), null, [ - AzureActiveDirectory::EXTRA_FIELD_ORGANISATION_EMAIL => $me['mail'], - AzureActiveDirectory::EXTRA_FIELD_AZURE_ID => $me['mailNickname'], + 'extra_'.AzureActiveDirectory::EXTRA_FIELD_ORGANISATION_EMAIL => $me['mail'], + 'extra_'.AzureActiveDirectory::EXTRA_FIELD_AZURE_ID => $me['mailNickname'], ] ); if (!$userId) {