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.

7 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"
    		/>

Leave a comment