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:

plugins/user/profile10/profile10.php

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:

plugins/user/profile10/profile10.xml

There are two entires we need to make:

  1. 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>

The two options above can be seen when the Joomla 2.5 site administrator is editing the user profile plugin's settings:
user-profile-plugin-manager

Like this Article?
joeygartin 2013-05-13 3:34 am
First, thanks for posting the steps to alter the base Joomla User. I think this is a huge feature for 2.5+. Lots of possibilities for customization! I did not see where there were changes made to the database structure to house the User information. Is this done on the users table or in a separate additional table? Either way, where is the code that saves this data to the db?

Login to comment.

Your Opinion Matters

... but we need to know what you're thinking!

I'm Brad Markle, your friendly Community Support technician, and I wrote the article you're looking at now. I like to think it's perfect, but I'm sure you have some suggestions. Please, let me know what they are!

Feedback
Your Email Address
Because we'd like to talk with you!

Latest Questions

If you need some help, submit your question to our Community!
We guarantee a response within 60 minutes (8am - 9pm EST, Monday - Friday)
Ask a Question!
Recent Questions
  1. how and where do I copy FB like button code into HTML to add to my web page please
  2. I get a database connection error. What name should I be using to configure my database connection?
  3. Unable to block .RU domains

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!