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):
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"
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"
The two options above can be seen when the Joomla 2.5 site administrator is editing the user profile plugin's settings:
Did you find this article helpful?
Thank you for your feedback!
Would you like to provide any additional feedback?
Optional, but our team may contact you for more information.
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?
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.
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?
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 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.
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.
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();
'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.
... 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.
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!
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.
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.
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.
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.
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!
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?
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">
This is the code of profile.php on line 174:
$fields = array(
This is the code of profile.xml in line 33:
<field name="register-require_speciality" type="list"