How to Lock User Profile Fields and Add Custom Fields in Moodle
If you manage a Moodle server or servers and the user accounts for your organisation, you might consider locking down some of the user profile fields such as their first name, surname and email address.
Lock User Profile Fields in Moodle
You can lock user profile fields as an administrator on the server via
Settings > Site Administration > Plugin > Authentication > Manual accounts.
You will be presented with a list of profile fields as found below. Once locked users no longer have the ability or permission to change these fields.
NOTE: Locking of User Fields are only applicable to accounts created manually either individually or via ‘Upload Users’. Use the drop down menu beside each field header to change its state, choosing from one of the following:
User Fields States:
- Unlocked
- Unlocked if Empty
- Locked
The following profile fields can be locked:
- First name
- Surname
- Email address
- City/town
- Country
- Language
- Description
- Web page
- ID number
- Institution
- Department
- Phone 1
- Phone 2
- Address
Create Custom Profile Fields in Moodle
Custom profile fields can be used in many ways to. You can create custom fields for the following:
- Sport Houses, Pastoral Houses, House System for point system, Residential Houses, Boarding House, University Accomodation, Classes, Additional postal or address information and more
Again, you will need to be logged on as Administrator to do this. To create a new user profile categories and fields go to:
Settings > Site Administration > Users > Account > User Profile Fields
Custom profile fields can be one of the following
- a menu of choices
- text area
- text input
- checkbox
- and may be set to required or not.
The custom fields must have the following:
- unique Short Name
- Name (displayed on the profile page)
The description while optional is useful to complete for your own reference.
Configuration options for custom fields are as follows:
- Is this field required? This is a simply, to make the field mandatory for the user accounts.
- Is this field locked? If enabled, once entered, the user can no longer edit the information.
- Should the data be unique? This could be registration ID, pass or ID number. If this option is enabled, the profile page update will run a validation check on the entry.
- Display on signup page? If open registration and sign-up is enabled, you can choose if the custom field is shown on the registration or signup page.
- Who is this field visible to? The three options are everyone, not visible therefore only to administrators and visible to user.
New profile fields will appear on each user’s profile page unless “Who is this field visible to?” is set to “Not visible” in which case only the administrator can see the field.
The fields can also be displayed on the signup page if “Display on signup page?” is set to “Yes” (although note that they will never be displayed if set to “Not visible”).
You can set the order in which your custom profile fields appear under the associated profile category using the up/down arrows on the User profiles fields page.
Advanced Applications of Custom Fields
Once a custom field is created, you can also apply this in the ‘Upload user’ process when creating new users or updating existing users.
e.g. taken from Moodle.org
A school has eight houses, named after its founders: Adderton, Coolock, Gorry, Loretto, McAuley, Mercedes, Tighe and Whitty. The site administrator can add a user profile field that offers a ‘Menu of choices’ to the user. A default value can also be selected. If the administrator decides to bulk upload House data for users via a .csv file, it is important to represent the above array of values as 1,2,3,4,5,6,7,8 in the file. That is to state, if a user belongs to Adderton House, the value ‘1’ should be entered for the ‘House’ user profile field in the given record.
Certain fields can be used by Moodle for administrative purposes or conditional access, see Restrict Access Based on Moodle User Profile Fields.