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

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Joomla Community Google+ Hangout #3

June 3rd, 2014

Thank you @RustyJoomla for letting me speak on the Joomla Community Google+ Hangout!

Click here to watch!

2013-05-12 11:34 pm
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?
2013-06-22 3:32 am
I have the same question, everything looks great but the custom fields are not being saved. What databases should I alter or do I need to make a new one? Where is this info saved?
Staff
5,889 Points
2013-06-24 11:23 am
The information is stored in the database tables that are set up for that specific plugin. The Changes are supposed to show up in the plugin manager. You should not need to create a separate database for the plugin.
2013-06-24 11:51 am
If I want to add a new field to the User Profile Plugin, then copying the plugin completely (and changing the name) and enabling my copy while disabling the default one makes sense. Adding information to the .xml & .php files so that the new field is displayed in the admin (and front end) makes sense. I am lost at how this new 'baseballteam' field will get recorded in the db (meaning the table for the plugin). Does the existence of a new field in the .php file array ($fields) automatically trigger the creation of a mysql table column for the plugin? If so, what is the default value type? I would imagine varchar, but is there a way to control that? To have a radio button for yes/no fields or int for values, etc?
Staff
5,391 Points
2013-06-24 3:03 pm
Hi @joeygartin and @lyndaray909, sorry for not responding sooner.

It's been a while since I wrote the tutorial series above, but I believe that the information is being stored as a json object. For example, instead of creating a new table in the database for the custom fields that you add, Joomla simply adds another variable to the json object in the database.

If you look at this article, you'll see that the "manifest_cache" field is just one field, but using json it stores many values.

I would recommend using phpMyAdmin to search the database to find which table and row your data is being stored in, unfortunately I don't know off hand. If that doesn't help, we'll go through our own tutorial ourselves again :) and figure out where exactly it is saving the data.

Let us know how it goes, we'll be happy to help if searching via phpMyAdmin doesn't help.

Thanks!
- Brad
2013-07-02 10:13 am
Thanks for the great tutorial BradM. I was able to find the data stored in the database under #_user_profiles but the data is empty under the User Profile tab. What needs to be done to store the data in the user profile? Any ideas or help is much appreciated.
Staff
7,266 Points
2013-07-02 11:17 am
Hello dellison1226,

It sounds like you want to add user profiles, and have them listed under the User Manager section. I am not familiar with how to accomplish this, I would recommend posting on Joomla's official support forum.

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul
2013-07-02 11:44 am
Thank you for the quick reply. I was able to find the problem to get the information to store correctly under user managers >> user profile.

For anyone that is interested on the file profile10.php (profile.php) on line 340 'userid' should be 'user_id' like ->where($db->quoteName('user_id') . ' = ' . (int) $userId). This is a Joomla bug.
Staff
7,266 Points
2013-07-02 12:07 pm
Hello dellison1226,

Thank you for replying with your solution! This will be helpful for other people as well.

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul
2013-07-04 5:55 pm
great tutorial. first, big thanks to Brad Markle for writing this. first i am new to joomla and i followed every step in the tutorial and everything worked for me but my concern is that at the back end, the profile plugin name changed to this plg_user_profile10 also the fields name equally changed e.g field name for address changed to PLG_USER_PROFILE_FIELD_ADDRESS1_LABEL, e t c the only profile name that did not change was the Favorite BaseBall Team. my question is, is this how it suppose to look? cause i noticed that when i installed the plugin, it installed but error was also reported:
JInstaller: :Install: File does not exist C:\xampp\htdocs\kjoomla\tmp\install_51d5ed3435f8a\profile\en-GB.plg_user_profile10.ini

Installing plugin was successful.
@John Paul thanks for helping. but want to ask this question am sorry for asking cause it may look too basic. on line 340, i didn't find anything like 'user_id' like ->where($db->quoteName('user_id') . ' = ' . (int) $userId) rather on line 322 i saw something related but different
$db = JFactory::getDbo();
$db->setQuery(
'DELETE FROM #__user_profiles WHERE user_id = '.$userId .
" AND profile_key LIKE 'profile.%'"
please where can i make the change here so that the field will populate in the database. ones again thanks for helping.
2013-07-04 5:59 pm
my joomla version is 2.5.11
2013-07-04 6:02 pm
dellison1226 am sorry for mistaking your name to John Paul, hope you forgive me for that
Staff
5,391 Points
2013-07-05 12:23 pm
Hi @kingsparadise,

I'm glad you found the tutorial series helpful. The error message regarding en-GB.plg_user_profile10.ini is stating that it couldn't find a language file for the new user profile plugin.

It's been quite a while since I looked at this tutorial series, but I found on this page:

Adding Custom User Profile Fields in Joomla 2.5 - Step 1/3 - Copy the Plugin

... it mentioned in steps 4 and 5 to copy the language files and to rename them. The file you are getting an error on, en-GB.plg_user_profile10.ini, is mentioned in step 5 and 6. Are you sure that you followed steps 4, 5, and 6?

It's hard to tell why you're getting that error, but I would double check and ensure you copied and rename the language file correctly.

Hope that helps!

Thanks,
- Brad
2013-07-23 5:26 am
here is a great video on how to do this.

http://youtu.be/2AyCzb2vTaU
Staff
7,266 Points
2013-07-23 12:43 pm
Hello Casenova,

Thank you for sharing, I enjoyed your video!

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul
2013-08-13 3:39 pm
This has (nearly) solved a massive issue for me. Thanks guys.
The only thing Im struggling with now is how to make some of the fields drop down or radio elements?

Any advice on that would be greatly appreciated :)

Mohsen
Staff
15,484 Points
2013-08-13 5:32 pm
Hello Mohsen,

Thanks for the question. I did a little digging and I may have found an answer. Try looking at this plugin - which states that the user profile fileds "can not be edited': custom profile fields for Joomla 2.5. Additionally, I searched around and found another answer Joomla 2.5 Custom field as dropdown. They have some code provided in the posts, and also some suggested add-ons that may also provide you another option.

I hope that helps! Please let us know if you require any further assistance!

Regards,
Arnel C.
2013-08-13 6:11 pm
Hi Arn,

Thanks for the exceptionally swift response!

I have managed to use the link to provided to follow the code on here: http://docs.joomla.org/Standard_form_field_and_parameter_types

Works like a charm, thank you!
2013-08-18 10:25 pm
Thank you. Here's the million $ question. How can I get that extra field to show up on the notification email I receive as administrator when someone registers? OR, how can I get the User Manger section in the backend to add that extra field as a column so I can see the user name, THAT NEW FIELD INFO, and all the rest. Because what's the use of collecting that info if I have to open each of the hundreds of users one at a time, expand the section that has the plug in fields just to see it? That can be a nightmare.

So the data is collected at registration, but I never see it unless I open EACH RECORD one by one. Hope that makes sense.
Staff
15,484 Points
2013-08-20 5:11 pm
Hello Pambesteder,

Thanks for the question! I had to do a little digging into several forums and I found this: Joomlapolis forum post. This post describes how to add extra field to an administrator email notification with a plugin and provides a link - which is still good (I checked it). The problem is that I'm not sure how valid this is with your version of Joomla. Check out the link and let us know if this helps.

If you continue to require assistance on the issue, please let us know.

Regards,
Arnel C.
2013-08-20 6:08 pm
Arnel.... ugh...no didn't help (maybe I'm just dense)

You sent info on how to modify a plugin (and not the original language files). But I didn't see in any of that how to make that show up on the email. It didn't give instructions on what to do IN the language notification email to put that extra field on it. So...sigh....still confused.
Staff
15,484 Points
2013-08-20 8:15 pm
Hello Pambesteder,

Sorry that didn't help. The instructions are a little vague, but basically it's telling you modify the english.php file for the plugin. Field names are added by adding the field with the square brackets around it.

I spent quite a bit of time looking through forums for this, and the CLOSEST thing I could find that resembles your question led to a post in the official Joomla forums that was posted in Feb 2007 - but never answered.

Also, remember that the article above is about using a PLUGIN to modify the fields. So this was NOT built into the existing Joomla functionality. That's probably the main reason you don't see the extra fields in the notification text. I also found this plugin: Powerful Email editor for Joomla. It's not free, but it MIGHT be the solution you need as you can customize the emails.

We are not coders for Joomla either, but we do support a lot of customers who use the application. One of the hardest things to try to support (for any application) are the third-party plugins. Typically the best thing you can do is either contact the developer of the plugin and ask for advice/support, or try to find a programmer/development team/online solution that has already addressed your question and derived a solution.

Sorry again for the ongoing confusion. I hope this helps to lead you to a possible solution for your email notification needs.

Regards,
Arnel C.
2013-09-14 1:31 pm
Hi everybody. I have this problem:
I created a custom field with type="list" and in the registration page and profile editing page works fine but in the page profile view shows me the value instead of the label. How do I show the label, do I have to edit the file components/com_users/views/profile/tmpl/default_params.php or something else. Help me please!
Staff
9,521 Points
2013-09-16 2:54 pm
Hello Carlo77,

If you were following along with this tutorial series the file you'd be editing in this case would be plugins/user/profile10/profile10.php or whatever you named the file when you copied the user profile plugin.

In this article's example the label would be Favorite BaseBall Team, are you saying that you are seeing the option value instead such as JDISABLED in the page profile view?

- Jacob
2013-09-17 5:12 am
I made modification directly on original profile plugin after I see that profile10 doesn't work, but there is the same problem also with this one.
I made 2 new fields: the second is a string like Favorite BaseBall Team and it work better in profile view (index.php?option=com_users&view=profile); the first is a list that there isn't in this tutorial. This is the code I used in profiles/profile.xml:
<field name="speciality" type="list" id="speciality" default="" description="PLG_USER_PROFILE_FIELD_SPECIALITY_DESC" filter="string" label="PLG_USER_PROFILE_FIELD_SPECIALITY_LABEL" message="PLG_USER_PROFILE_FIELD_SPECIALITY_MESSAGE">
<option value="">PLG_USER_PROFILE_FIELD_SPECIALITY_SELECT</option>
<option value="1">PLG_USER_PROFILE_FIELD_SPECIALITY_OPTION_A</option>
<option value="2">PLG_USER_PROFILE_FIELD_SPECIALITY_OPTION_B</option>
<option value="3">PLG_USER_PROFILE_FIELD_SPECIALITY_OPTION_C</option>
<option value="4">PLG_USER_PROFILE_FIELD_SPECIALITY_OPTION_D</option>
<option value="5">PLG_USER_PROFILE_FIELD_SPECIALITY_OPTION_E</option>
<option value="6">PLG_USER_PROFILE_FIELD_SPECIALITY_OPTION_F</option>
<option value="7">PLG_USER_PROFILE_FIELD_SPECIALITY_OPTION_G</option>
</field>
<field
name="other_speciality"
type="text"
id="other_speciality"
description="PLG_USER_PROFILE_FIELD_OTHER_SPECIALITY_DESC"
filter="string"
label="PLG_USER_PROFILE_FIELD_OTHER_SPECIALITY_LABEL"
message="PLG_USER_PROFILE_FIELD_OTHER_SPECIALITY_MESSAGE"
size="30"
/>

This is the code of profile.php on line 174:
$fields = array(
'speciality',
'other_speciality',
'address1',
'address2',
'city',
'region',
'country',
'postal_code',
'phone',
'website',
'favoritebook',
'aboutme',
'dob',
'tos',
);

This is the code of profile.xml in line 33:
<field name="register-require_speciality" type="list"

description="PLG_USER_PROFILE_FIELD_SPECIALITY_DESC"
label="PLG_USER_PROFILE_FIELD_SPECIALITY_LABEL"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
<option value="0">JDISABLED</option>
</field>

<field name="register-require_other_speciality" type="list"

description="PLG_USER_PROFILE_FIELD_OTHER_SPECIALITY_DESC"
label="PLG_USER_PROFILE_FIELD_OTHER_SPECIALITY_LABEL"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
<option value="0">JDISABLED</option>
</field>

and line 189:
<field name="profile-require_speciality" type="list"

description="PLG_USER_PROFILE_FIELD_SPECIALITY_DESC"
label="PLG_USER_PROFILE_FIELD_SPECIALITY_LABEL"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
<option value="0">JDISABLED</option>
</field>

<field name="profile-require_other_speciality" type="list"

description="PLG_USER_PROFILE_FIELD_OTHER_SPECIALITY_DESC"
label="PLG_USER_PROFILE_FIELD_OTHER_SPECIALITY_LABEL"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
<option value="0">JDISABLED</option>
</field>

In administrator > plugins > User - profile I set Required in all new fields.

This is the HTML of Profile editing page index.php?option=com_users&view=profile&layout=edit
<dt><label title="" class="hasTip required" for="jform_profile_speciality" id="jform_profile_speciality-lbl">Speciality<span class="star">&nbsp;*</span></label></dt>
<dd><select class="required" name="jform[profile][speciality]" id="jform_profile_speciality" aria-required="true" required="required">
<option value="">- Select speciality -</option>
<option selected="selected" value="1">Cardiology</option>
<option value="2">Electrophysiology</option>
<option value="3">Sport Medicine</option>
<option value="4">Internal Medicine</option>
<option value="5">General Practitioner</option>
<option value="6">Neurology</option>
<option value="7">Other, specify...</option>
</select>
</dd>
<dt><label title="" class="hasTip required" for="jform_profile_other_speciality" id="jform_profile_other_speciality-lbl">Other speciality<span class="star">&nbsp;*</span></label> </dt>
<dd><input type="text" size="30" class="required" value="" id="jform_profile_other_speciality" name="jform[profile][other_speciality]" aria-required="true" required="required"></dd>

And this is the HTML in profile view index.php?option=com_users&view=profile
<dt>Speciality</dt>
<dd>1</dd>
<dt>Other speciality</dt>
<dd>No Information Entered</dd>
2013-09-17 6:10 am
I have Joomla 2.5.14 Stable [ Ember ]
Staff
7,266 Points
2013-09-17 9:34 am
Hello Carlo77,

Thank you for sharing!

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul
2013-12-24 5:09 am
hello, i have added custom fields, in plugin settings appeared parameters with field name to control whether field is optional, required or disabled, but in registration dialog, or when you edit your profile, all newly added fields don't using these parameters and always "optional". changing parameters does not take effect.
i have modified all files as described in this instruction
joomla 2.5.17
2014-01-09 3:32 am
Hi , I have faced same problem as "myname" , the fields shows optional in registration page even if I have set it as required. One more problem is registration page shows language variable instead of its value ie. it shows PLG_USER_PROFILE_FIELD_PHONE_LABEL instead of "Phone". Same problem into admin area user profile. How can I get rid of it?
2014-01-09 5:10 am
Hi
I have found the solution of display language variable instead of its value. I have made mistake that use capital letter into language file name e.g. "en-GB.plg_user_profilePkachhia.ini" , but when file loaded it find for "en-GB.plg_user_profilepkachhia.ini". Debug using enable the debug language option from admin panel of joomla.
2014-03-12 6:53 am
Hi
If I want to add image filed for the picture of user like k2. what sould I do?
n/a Points
2014-04-24 3:56 am

Thanks for the tutorial. Although i am very much late to view this, but i have a question. In admin panel, the field is displaying perfectly fine. But i am not able to see the input field on the front end form. Where i need to the change to make it viewable on front end.

 

Thanks

Staff
7,372 Points
2014-04-24 8:27 am
If all steps are taken through each article in the full tutorial series on adding customer user profile fields, the customer user profile fields would have been added without any additional configuration. I recommend going back through all of the previous articles in the series to ensure that all steps have been appropriately taken.
n/a Points
2014-04-26 1:10 am

Is it possible to add image field for profile picture

Staff
9,521 Points
2014-04-28 4:19 pm
Hello raz, and thank you for your question.

It does look like you should be able to use a Joomla media form field type as is discussed in this post on the Joomla forums.

Please let us know if you had any further questions.

- Jacob

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

35 Questions & Comments

Post a comment

Back to first comment | top

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!