There are ways to do so.

  1. There are some predefined fields in User-Profile plugin. Like address or ZIP. So if you want to use them just activate this plugin and configure it as you like.
  2. If you want to add your own custom fields you must have access to database where your site data is stored.


So follow next steps

  • Add fields to #__users table corresponding to desirable fields. The next talk is about string fields.
  • Edit components/com_users/models/form/registration.xml file and add fields you need. For example
    <field name="university" type="text"
        filter="string"
        label="COM_USERS_REGISTRATION_UNIVERSITY"
        message="COM_USERS_REGISTRATION_UNIVERSITY_MESSAGE"
        required="true"
        size="30"
        />

    Don’t forget to add COM_USERS_REGISTRATION_UNIVERSITY and COM_USERS_REGISTRATION_UNIVERSITY_MESSAGE to COM_USERS language file.
    The default language file is located at language/en-GB/en-GB.com_users.ini.

  • Also add same fields to profile.xml so users can edit their data.
  • If you want to see added fields in user table in your administrator panel, edit administrator/components/com_users/views/users/tmpl/default.php and add to table class="adminlist" desirable columns. For example, add column header
    <th class="left">
        <?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_UNIVERSITY',
        'a.university', $listDirn, $listOrder); ?>
        </th>
    

    and cell to line with user data

    <td class="center">
        <?php echo $this->escape($item->university); ?>
    </td>
    

    Don’t forget to add language variables to your administrator language files.

  • Also you may add your fields to user edit page in your administrator panel if you like. Just edit file administrator/components/com_users/views/user/tmpl/edit.php.
    Sorry for my mistake. In order to see your fields on user edit page in administration panel you must edit following file: administrator/components/com_users/models/forms. Just we’ve made before with user registration. For example,

    <field
    	name="city"
    	type="text"
    	filter="string"
    	label="COM_USERS_REGISTRATION_CITY"
    	message="COM_USERS_REGISTRATION_CITY_DESC"
    	required="true"
    	size="30"
    />
    

    Don’t forget to add COM_USERS_REGISTRATION_CITY and COM_USERS_REGISTRATION_CITY_DESC to administration language file which is located at administrator/language/en-GB/en-GB.com_users.ini.

Share
Posted By admin

    7 Responses to “How to add custom fields to Joomla 1.7 registration form”

  1. awaisahmad says:

    Excellent tutorials:
    can you plz give a lot more details i-e how to store data of specified field in a database and where is the language file.

    I want to add comboboxes in the form. By changing in user.xml i got that fields but dont get their values in database can you u plz elaborate it little.

    Thanks and waiting for you answer.

    • admin says:

      I’m very sorry for so long delay. I’ve added information about the location of language files. As far as comboboxes are concerned I don’t know exactly how to do so. It may be helpful for you to look how radio switched are made in administrator/components/com_users/models/forms.

  2. davilafran says:

    Hi.

    Thanks for the explanation.

    The final step for administrator/components/com_users/views/user/tmpl/edit.php is not so trivial for me.

    Also the creation of a user from the admin control panel doesn’t allow me to use the custom fields that works in the login module.

    Could you explain it with more detail please? Thanks.

    • admin says:

      I’ve terribly sorry for so long delay. I’ve added information about how to edit user in administration panel. Hope that will help.

  3. google.com Andrea Gesti says:

    Hello. Very helpfull!

    How can I edit the user edit page in admin panel?

    Than, i would like to put some extra text in the registration form.
    I make a checkbox and i would like to put a link to a page that show terms & condition, for example.
    How can I do it?

    I’have been traiyng for days but with no results.

    • admin says:

      I’ve terribly sorry for so long delay. I’ve added information about how to edit user in administration panel. Hope that will help.
      As for link to terms & conditions: have you tried common <a> tag and terms as regular article?

  4. admin says:

    I’m terrible sorry for not replying so long. My spam system somehow went wrong.

Leave a Reply

You must be logged in to post a comment.