Custom fields in a user profile are additional data fields that you can add to a user's profile to store information beyond the standard set of user attributes, such as username, email address, and password. These custom fields allow you to collect, store, and display specific information about a user on your MetaFox site. MetaFox supports the custom group "About" and some certain custom fields by default and you can have a quick look on how custom fields are displayed on user profile below.
In this article, we are going to walk you through step-by-step to create new custom groups as well as their custom fields. To explain you more conveniently, we will add a new custom group "Working Info" and a custom field "Company Name" into this group
Add new custom group
Let's log into AdminCP Dashboard and go to Members > Custom Fields > Manage Custom Groups
In this page, you will see the list of all available of custom groups. The About group is added by default.
Click on the Add Group button at the top menu bar, then fill info of new group into the form as below.
Then click the Create button. You can see that a active custom group "working" is now created.
Add custom fields to custom group
Now, we will add a custom field "Company Name" info the custom group "Working Info" added in the previous step.
Let's go to AdminCP > Members > Custom Fields > Add Custom Field page and fill the form as screenshot below.
There are many supported options for Editing Component such as Radios, Checkbox, TextArea, etc. In this example, we choose using Text for users to input.
Once completing the form, you can click on the Create button.
Congratulation! You just finished adding a custom field into user profile. Users can fill the info when editing their profiles. The new custom field will display on the About tab of User Profile page now.
Translate phrases of custom fields
If your MetaFox site supports multi-languages, you can easily translate phrases of new add custom field as below
Let's go to AdminCP > Localization > Phrases. The translation keys associated with the label and description of your custom field "companyname" are:
- profile::phrase.companyname_description
- profile::phrase.companyname_label
You can add above keys and their phrases to the supported languages. Then click on Save Changes button.
Now, clear the site cache and refresh the profile page(s) in that language, you will see the label and description of custom field are translated accordingly.