Custom User Fields in Joomla
In this guide, you will learn about custom user fields in Joomla. Custom user fields are pieces of information attached to each user, which can be accessed through the user profile. They can also be used by third-party extensions. We will focus on the user profile portion in this guide, not the development side.
Joomla provides several built in user profile fields you can select and enable through the plugin manager. If you're looking to add commonly used fields like phone numbers and addresses to a user's profile, check out the user profile plugin tutorial. If you need more customized fields, this guide is for you.
There are many types of custom user fields with unique properties. You can have fields for text, fields for numbers, fields for dates, fields for messages, and more.
Custom user fields are sorted into field groups. You don't have to put your fields in groups, but it's a good idea. If you don't put your custom fields in a group, they will just be placed under a heading that says "Fields" which isn't very descriptive.
Select the "Field Groups" option under the "Users" section of the administration menu. Then create a new field group. Give it a descriptive name and save it. For this example, I'm going to be adding custom fields related to a fictitious software development company.
To create a custom field, navigate to the "Fields" option under "Users" in the administration menu. Click "New" and create a new field.
There are over a dozen different types of user fields. The most common ones you'll probably want to use include:
- A standard text box where users can enter a short string of characters.
- Load the full WYSIWYG editor and allow users to write a longer message formatted in HTML.
- Text Area
- A longer version of the text box without HTML formatting. For longer messages that don't need to be formatted to HTML.
- A dropdown list with different options set by the administrator
- Radio buttons are the circle checkboxes you click that allow you to only select one option.
- Users can check one or multiple options.
To learn more about the specifics of each option, look at the Joomla documentation by clicking "Help" from the new user field screen. It will give you a breakdown of each option. We're going to touch on just a few of the options. The individual settings for each field type varies, but the general idea is the same.
In the screenshot, I create a new field titled "Supervisor Name" and assign it to the "Corporate Information" group I created earlier. This is going to contain the username of the person's direct supervisor/manager. So I selected the default "text" option for field type.
Now when I visit my front end profile as a registered user, the field is displayed in my profile.
Note that at this time, as a registered user (not an Admin), when I click edit profile, I can see the field, but I cannot change it myself. I do not have that permission, as a registered user. The way it's currently set up, only an admin would be able to change the field for me.
To edit this new custom field as an administrator, we can go to the user manager and open the user we want to edit.
A new tab will appear with our field group name under the user. Here, we can change all the fields for this particular user.
Now, when I visit my front end user profile as the registered user, it tells me the name of the manager assigned.
Making It User-Editable
The field can be made editable by the user themselves by changing the field permissions. To do this, open the field, go to the permissions tab, and set the "Edit Custom Field Value" to "Allowed" for registered users. Then save the field.
Now, when I go to edit my profile as a registered user, I can edit the name of my direct supervisor myself.
For a field like this, I probably wouldn't actually make it user-editable. I'd only allow admins to update the user's manager information.
Other Common Field Types
I have added several more fields to the user profile. The screenshots show what it looks like on the back end and the front-end.
I have kept the text field, added a list field, a calendar field, and a radio field.
You can click the links below to see what my settings look like for each field.