-
Improvement
-
Resolution: Fixed
-
Major
-
2.6, 3.11
-
MOODLE_26_STABLE, MOODLE_311_STABLE
-
MOODLE_311_STABLE
-
MDL-45242-master -
At present the "Show user identity" option under "User Policies" only permits the following fields to be shown as part of the user identity.
It would add some additional flexibility if custom user profile fields could be presented as an option.
For instance, our ID number field is filled with an institutionally unique identifier for each user, however this information is pretty much only internally used.
Students are issued with a Registration Number each time the start a programme of study. This is much more commonly used to identify students on a daily basis, but as a custom profile field it cannot be shown on some of the more useful locations, such as the list of submissions into a class, user selection lists (e.g. enrolment)
Implementation
New behaviour for users
- The admin setting lists all 'text' type custom fields that have a maximum length of 255 characters or less, so you can choose these fields. Updated description text warns users that the custom fields do not work everywhere. [See screenshot]
- I have modified the code so that three features work with these options: 'Browse list of users', the Participants page list of users, and the 'Enrol' option on the participants page.
- In other screens, behaviour will be as before with custom fields not shown.
Developer changes
- Custom fields can be specified in $CFG->showuseridentity as 'profile_field_<shortname>', e.g. 'profile_field_favouritecolour'.
- New API \core\user_fields can be used to create lists of user fields, and SQL query fragments for getting them (which use LEFT JOIN to get any custom fields). It covers identity fields (showuseridentity), fields required for user pictures, and fields required for full names.
Compatibility
- The corresponding existing functions are all deprecated: get_extra_user_fields(), get_extra_user_fields_sql(), get_user_field_name(), get_all_user_name_fields(), and user_picture::fields(). All the features from these functions are subsumed into the new API.
- All existing code that called the deprecated functions, or used the $CFG variable directly, has been modified to use the new API. (The API option to exclude custom profile fields has been used, so that this massive change could be made without significant code changes.)
Modifying existing code
- As noted I only made it work for three features because it's far too much effort (and testing) to fix everywhere.
- It is usually relatively easy to fix each individual feature; the three commits for these features are quite short.
- caused a regression
-
MDL-71131 Browse list of users page showing all name fields after MDL-45242
- Closed
-
MDL-71215 User fields: Some remaining uses of deprecated functions
- Closed
-
MDL-71836 Enrol users: Cannot search by username
- Closed
- has a non-specific relationship to
-
MDL-28451 Convert some of the "standard" user profile fields into custom user profile fields.
- Closed
- has been marked as being related by
-
MDL-78920 Show custom drop down profile fields in showuseridentity setting
- Open
-
MDL-28452 Convert user profile fields for messaging/networking into custom profile fields
- Closed
-
MDL-71051 Always use the same method to retrieve list of user profile fields
- Closed
-
MDL-71889 Explain constraints on custom user identity fields in interface
- Closed
- has to be done before
-
MDL-70456 Add custom user field support to all places that display user identity
- Open
- is duplicated by
-
MDL-56611 "showuseridentity" not able to respect additional profile fields
- Closed
-
MDL-59587 Allow custom profile fields to be only viewed by teachers and parents (requesting 2 new view permissions)
- Closed
- Testing discovered
-
MDL-71099 Move user_fields from core to core_user
- Closed
- will help resolve
-
MDL-28543 Custom User Fields, in Participants List.
- Closed
-
MDL-50763 Create a pronoun field
- Reopened
-
MDL-20919 Again: Allow admin user to choose the fields shown in the 'Browse List of Users' page
- Closed
-
MDL-69922 Display custom profile fields in user lists at site and course level
- Closed