Joomla 2.5 has reached its end of life as for 12/31/2014. Please be advised this may be a security risk to your website. You can view more information about the end of life here.
In our last few tutorials, we have been showing you the steps in how to add custom fields to the Joomla 2.5 user profile plugin. At this point we have copied the user profile plugin and updated the user facing form that asks them to enter in the new field. Our next step is to update the plugin’s parameters and allow the site Administrator to control whether the field is optional, required, or disabled.
Again, in this tutorial series we have been updating the Joomla 2.5 user profile plugin and adding a custom user profile field that allows the user to enter their favorite baseball team. We need to allow the site administrator to determine whether the user needs to add something for this field for not.
The first file we need to edit is:
We are making an update around line 171, and adding the following line (highlighted in red):
$fields = array( 'address1', 'address2', 'city', 'region', 'country', 'postal_code', 'phone', 'website', 'baseballteam', 'favoritebook', 'aboutme', 'tos', 'dob', );
The next file we will need to edit is:
There are two entires we need to make:
- User profile fields for registration and administrator user forms
The first item controls the form users fill out when registering. We added the following at line 109:
<field name="register-require_baseballteam" type="list" description="During registration, if you have a favorite baseball team, enter it here." label="Favorite BaseBall Team" > <option value="2">JOPTION_REQUIRED</option> <option value="1">JOPTION_OPTIONAL</option> <option value="0">JDISABLED</option> </field>
The next item is added at line 248, and controls whether the user can edit the field’s value after they’ve initially registered and then try to edit their profile:
<field name="profile-require_baseballteam" type="list" description="If you have a favorite baseball team, enter it here." label="Favorite BaseBall Team" > <option value="2">JOPTION_REQUIRED</option> <option value="1">JOPTION_OPTIONAL</option> <option value="0">JDISABLED</option> </field>