How to Add New Attributes (Fields) to the User Registration Form in Joomla?

Often, we receive requests for adding new attributes (or fields) to the user registration form in Joomla. Such attributes are usually specific to our client’s industry. A very recent example is a client of ours who runs a small magazine, and wanted to add the following 2 fields: “Registered” (which is of type boolean) and “Subscription Expiry Date” (which is of type date).

The procedure consists of the following steps:

  1. Add the fields to the table jos_users in the database
  2. Update the JTableUser class to accommodate the new fields
  3. Update the form in the website’s backend

Adding the fields to the table

This is the easiest step. Just go to phpMyAdmin, select the database of your website, and click on the jos_users table (assuming you left the default “jos_” table prefix), and then click on “Structure” on the top, and then click Add the 2 fields. Let’s call the first one registered (type is tinyint(1)) and the second one subscription_expiry_date (type is date). Let’s index both fields (makes searching faster).

Update the JTableUser class

Follow the below and this step will be a breeze:

  • Open the file libraries/joomla/table/database/table/user.php.
  • Search for this line: var $params = null;
  • Add the following lines after the above line:


    var $registered = null;
    var $subscription_expiry_date = null;

Update the registration form

This is the hardest step and trust us, it shouldn’t take long. Again follow the below and you should be OK:

  • Open the file administrator/components/com_users/views/user/tmpl/form.php.
  • Search for this line:

    <tr>
    <td>
    <?php echo JText::_( 'Receive System Emails' ); ?>
    </td>
    <td>
    <?php echo $this->lists['sendEmail']; ?>
    </td>
    </tr>

  • Add the following lines after the above line:
    <tr>
    <td>
    <?php echo JText::_( 'Registered' ); ?>
    </td>
    <td>
    <?php echo $this->lists['registered']; ?>
    </td>
    </tr>
    <tr>
    <td>
    <?php echo JText::_( 'Subscription Expiry Date' ); ?>
    </td>
    <td>
    <input type="text" name="subscription_expiry_date" id="subscription_expiry_date" size="40" value="<?php echo $this->user->get('expiry_date'); ?>" />
    </td>
    </tr>
  • Open the file administrator/components/com_users/views/user/view.html.
  • Find this line: $lists['sendEmail'] = JHTML::_('select.booleanlist', 'sendEmail', 'class="inputbox" size="1"', $user->get('sendEmail') );
  • Add the following line after the above line: $lists['registered'] = JHTML::_('select.booleanlist', 'registered', 'class="inputbox" size="1"', $user->get('registered') );

That’s it! You’re done!

Now we don’t recommend anyone that doesn’t have a programming experience to do the above. If you try the above and run into problems, or if you want someone else to do it for you, then go ahead, contact us. Our rates are very reasonable, and we’ll get the job done in no time.

12 Responses to “How to Add New Attributes (Fields) to the User Registration Form in Joomla?”
  1. Pingback by Docman Customization | itoctopus — July 7, 2011 @ 10:53 am

    […] – We added fields to the users table to reflect the registration status to each plan (for example, we have a field called plan_a which is a boolean, and is defaulted to 0, and another field which is plan_a_expiry_date, which is of type date). You can see how to add fields to the user’s form here. […]

  2. Comment by faten — November 30, 2011 @ 6:13 am

    hi, i would like to ask you regarding this step -> Open the file administrator/components/com_users/views/user/tmpl/form.php. seems like i cannot file the file in my joomla folder. what should i do?

  3. Comment by Fadi — November 30, 2011 @ 6:43 am

    Hi Faten,

    This is odd. The file should be there, it’s a very important file for Joomla. Are you sure you’re searching in the right place?

    If you want we can help you, just contact us!

  4. Comment by jammy — January 4, 2012 @ 3:31 am

    I can’t also find form.php file..I am using Joomla 1.7 version

  5. Comment by Fadi — January 4, 2012 @ 4:51 am

    Hi Jammy,

    Again, this is odd, the file should be there. Please contact us so we can help you with your Joomla problem.

  6. Comment by jinesh — February 18, 2012 @ 4:41 am

    I am using Joomla 1.7.i can’t find administrator/components/com_users/views/user/tmpl/form.php.

    I want to add a radio button field.

  7. Comment by Fadi — May 17, 2012 @ 2:26 pm

    For Joomla 1.6 and higher (1.7 and 2.5.x), you can edit the user’s form (in the admin area) by editing the file /administrator/components/com_users/models/forms/user.xml . In short, you will need to edit the XML file user.xml in order to add/delete/modify fields to your admin section.

    For example, if you want to add a field called city, then all you need to do is to add the following to the XML file:

    <field name="city" type="text"
    			class="inputbox"
    			description="City"
    			label="City"
    			required="true"
    			size="30"
    		/>
  8. Comment by Navjot — July 18, 2012 @ 6:18 am

    Hi
    I am using joomla 1.7.3 but i am not able to find var $params = null;. My user.php file is containing different code that doesn’t match the one you have displayed above.

    Please help me i need to fix this issue ASAP.

  9. Comment by Fadi — July 18, 2012 @ 6:37 am

    Hi Navjot,

    Please take a look at my comment above on how to add new fields for Joomla 1.6 and above (including Joomla 1.7.3)

  10. Pingback by Why Migrate to Joomla 2.5? | itoctopus — September 9, 2012 @ 9:16 pm

    […] It is very easy to extend Joomla 2.5: Want to add a few more fields to the registration form in the backend? You can do that by slightly modifying the users table (to add the new fields) and by editing a singly XML file. In Joomla 1.5.26, the process is much more complicated. […]

  11. Comment by Peter Zoomers — October 14, 2012 @ 3:11 am

    How can I make a inputbox which only can be filled in by the administrator. I need a inputbox where the administrator can add some text for every user. So every user gets his own comment. When the user logs in he can see the text of the administrator. Is there a module or component like this, do you have suggestions?

  12. Comment by Fadi — October 14, 2012 @ 11:22 pm

    Hi Peter,

    There are two ways to do this:

    1- Add a field to the users table and then add that same field to the form. Call the field “comment” and add it only to Joomla’s backend where only the admin can change it. Once that is done, the view to display the user’s profile page on the frontend should be overriden to include that comment.

    2- Another way for doing this is to develop a component from scratch that will allow admins to add comments to users from the backend (in a new table), and then create a module that will display that comment for logged in users.

    Both methods are not that complicated.

Leave a comment