Skip to content

dart-creations.com

Advertisement
Home arrow Joomla arrow Joomla Tutorials arrow Adding more fields to the Joomla 1.5 Registration page
Print E-mail
Wednesday, 01 October 2008

Adding more fields to the Joomla 1.5 Registration page

Warning: Joomla Hack! The following code involves modifying the core Joomla code. This has intrinisc drawbacks, i.e. any time you upgrade you'll have to redo the code, or lose this functionality

Make sure you take backups before you do this change! 

The Joomla Registration page usually contains enough information for most website. Users who want enhanced user information, typically go for Community Builder which allows extensive user registration fields. However, it is entirely possible to create additional registration fields without installing any components, by modifying a few lines in the Joomla core code. Here's how to do it.

In this example, we will be adding Business and Phone to the user registration field, however you can modify the example to add any fields you want to.

Step 1 - Add fields to the Users table

The first thing you need to do is to add the new fields into the Users table into the database. Using phpmyadmin or otherwise add the fields to the users tabl. The following SQL command adds the fields, however you can add these in any way you want:

 

ALTER TABLE jos_users ADD business VARCHAR (100) NO NULL AFTER name;
and
ALTER TABLE jos_users ADD phone VARCHAR (100) NO NULL AFTER business;


Once you have created the columns, verify that they have been created correctly and move on to the next step.

Step 2 - Modify the code

You'll need to modify a total of 4 files:

1. Modify the user class to include the new files in libraries/joomla/database/table/user.php

    var $name = null;
    /**
    * The login name
    *
    * @var string
    */

    var $username = null;

var $business = null;
var $phone = null;

2. Modify the code which displays the registration page components/com_user/views/register/tmpl/default.php 

    <tr>
    <td width="30%" height="40">
    <label id="namemsg" for="name"><?php echo JText::_( 'Name' ); ?>: </label> </td>
    <td>
    <input type="text" name="name" id="name" size="40" value="<?php echo $this->user->get( 'name' );?>" class="inputbox required" maxlength="50" /> * </td>
    </tr>

<tr>
<td width="30%" height="40">
<label id="businessmsg" for="business"><?php echo JText::_( 'Business' ); ?>: </label> </td>
<td>
<input type="text" name="business" id="business" size="40" value="<?php echo $this->user->get( 'business' );?>" class="inputbox required" maxlength="50" /> * </td>
</tr>
<tr>
<td width="30%" height="40">
<label id="phonemsg" for="phone"><?php echo JText::_( 'Phone' ); ?>: </label> </td>
<td>
<input type="text" name="phone" id="phone" size="40" value="<?php echo $this->user->get( 'phone' );?>" class="inputbox required" maxlength="50" /> * </td>
</tr>

     



    3. Modify the view of the users list: components/com_user/views/user/tmpl/form.php



    <tr>

      <td width="120">
      <label for="name">
      <?php echo JText::_( 'Your Name' ); ?>:
      </label>
      </td>
      <td>
      <input class="inputbox" type="text" id="name" name="name" value="<?php echo $this->user->get('name');?>" size="40" />
      </td>
      </tr>
      <tr>

    <td width="120">
    <label for="business">
    <?php echo JText::_( 'Business' ); ?>:
    </label>
    </td>
    <td>
    <input class="inputbox" type="text" id="business" name="business" value="<?php echo $this->user->get('business');?>" size="40" />
    </td>
    </tr>
    <tr>
    <td width="120">
    <label for="phone">
    <?php echo JText::_( 'Phone' ); ?>:
    </label>
    </td>
    <td>
    <input class="inputbox" type="text" id="phone" name="phone" value="<?php echo $this->user->get('phone');?>" size="40" />
    </td>
    </tr>

     

    4. Edit the page which displays the users in the backend: administrator\components\com_users\views\user\tmpl\form.php

    <tr>
                        <td class="key">
                            <label for="email">
                                <?php echo JText::_( 'Email' ); ?>
                            </label>
                        </td>
                        <td>
                            <input class="inputbox" type="text" name="email" id="email" size="40" value="<?php echo $this->user->get('email'); ?>" />
                        </td>
                    </tr>

    <tr>
                        <td class="key">
                            <label for="business">
                                <?php echo JText::_( 'Business' ); ?>
                            </label>
                        </td>
                        <td>
                            <input class="inputbox" type="text" name="business" id="business" size="40" value="<?php echo $this->user->get('business'); ?>" />
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            <label for="phone">
                                <?php echo JText::_( 'Phone' ); ?>
                            </label>
                        </td>
                        <td>
                            <input class="inputbox" type="text" name="phone" id="phone" size="40" value="<?php echo $this->user->get('phone'); ?>" />
                        </td>
                    </tr>

     

    That's it! You now have a couple of additional fields in the users table, and more information available to use. Thanks goes to jtullous from the Joomla Forums who supplied the code.

    Make sure you take backups before you do this change!

       

    Comments
    Search RSS
    nikhil patel  - jayswaminarayan   |122.169.11.xxx |2008-10-16 13:05:58
    it was really helpful and mind blowing description u have given of all thing ,i
    rally enjoy it
    thnks Nikhil Patel

    nikhil.07patel@gmail.com
    izzyl  - hi   |Registered |2008-10-24 01:53:22
    any screenshot of that code u made?
    Chidu  - Joomla user   |121.247.149.xxx |2008-10-30 12:38:29
    Its very useful for the beginners
    lostful  - i cant make it :(   |190.154.200.xxx |2008-10-30 18:15:43
    it works all except the 4 step, maybe it is because im in joomla 1.5 and i cant
    find the location you mention

    the closest one i find is
    administrator\components\com_users\vie
    ws\users\tmpl

    however, theres no change on the backend user manager
    list
    mark thomson  - ceo   |80.133.163.xxx |2008-11-06 13:36:12
    i can't find the files you want to modify...
    DART  - Step 4 - Missprint fixed   |SAdministrator |2008-11-06 19:21:02
    There was a small missprint in Step 4 which has now been updated with the
    correct file.
    megan   |80.133.163.xxx |2008-11-07 08:21:37
    i can't find any of the files you mentioned that need to be modified.
    is this
    j1.0 or j1.5?
    DART  - Joomla 1.5   |SAdministrator |2008-11-07 09:35:27
    The hack is for Joomla 1.5
    megan   |80.133.163.xxx |2008-11-07 11:09:01
    Hello again,

    is there anywhere a similar tut for 1.0?
    Would really help me out!
    DART  - Joomla 1.0   |SAdministrator |2008-11-07 11:58:16
    Haven't done it for Joomla 1.0, maybe you could try Community Builder?
    dgawebdesign.com  - Not save   |213.213.32.xxx |2008-11-13 18:35:13
    Not save form register.

    Where is the problem???

    I use joomla 1.5.7
    daniel  - Could not instantiate mail fun   |201.153.92.xxx |2008-11-26 00:11:38
    Everything is PERFECT! I just have a question... when a new user register in my
    site this error appears:

    Could not instantiate mail function.

    Then the good
    stuff:

    Your account has been created and an activation link has been sent to
    the e-mail address you entered., etc..

    Any ideas why this error happens? Thanx!
    DART  - Could not instantiate   |SAdministrator |2008-11-26 09:29:04
    Daniel,

    the path to your mailing library might be different than the default,
    or mail is not setup correctly on your server. Best is to speak to the web host
    you are using to help you out with this.
    Huey  - How to add a drop-down?   |88.14.66.xxx |2009-01-14 15:42:10
    Thanks! Great tutorial, but..
    How to add a drop-down select list? I like a
    select list with drop down with country (Spain, Puerto Rico, Brazil,
    etc..)

    Thanks another time
    DART  - Drop down list   |Administrator |2009-01-14 18:21:28
    Hi Huey,

    you just need to add standard HTML Select functionality ... take a
    look at the following example:
    http://www.w3schools.com/html/html_forms. asp
    amar  - Adding more fields to the Joomla 1.5 Registration   |122.162.170.xxx |2009-01-29 06:16:56
    I did as well as "http://www.dart-creations.com/joomla/joomla-t
    utorials/adding-more-fields-to-the-joomla-registra tion-page.html" but not
    show effect. so please help me.
    Evgeniy  - Russian logistic     |212.152.35.xxx |2009-02-06 11:49:10
    It is much in more details described on sionet.ru
    Kane  - Cannot redeclare class JUser   |119.12.30.xxx |2009-02-24 09:28:25
    Just tried this on Joomla! 1.5.9 Production/Stable - now I get the error message
    "Fatal error: Cannot redeclare class JUser in
    /home/emspa1/public_html/nsw/libraries/joomla/data base/table/user.php on line
    28" any time I try and do anything to do with users!

    It wasn't there before
    and removing ALL modifications made doesn't even fix it!

    HELP!
    flaviusss  - re: Cannot redeclare class JUser   |187.37.150.xxx |2009-11-05 03:31:36
    Kane wrote:
    Just tried this on Joomla! 1.5.9 Production/Stable - now I get the error
    message "Fatal error: Cannot redeclare class JUser
    in /home/emspa1/public_html/nsw/libraries/joomla/data base/table/user.
    php on line 28" any time I try and do anything to do with users!

    It
    wasn't there before and removing ALL modifications made doesn't even
    fix it!

    HELP!


    Hey Kane, please, I need to know what did you do to get this damn thing
    done! I've tried everything... would you please send me the solution
    to my e-mail? flaviusss@gmail.com. Thank you!
    Boaz  - WOW - this is GREAT!!!   |84.109.181.xxx |2009-02-25 20:55:59
    Thanks - it works GREAT!!!
    Akshay Chandra     |118.94.71.xxx |2009-03-04 10:33:19
    THANKX A TON!

    So many thanks to one who created this code and thanks a ton
    to one who posted this article.

    I wasn't paid to do the edit for my client,
    otherwise i would had forwarded the full amount to one who created and posted
    this article.

    Regards
    Darko   |12.153.37.xxx |2009-03-04 20:12:51
    Works like a charm. But how about a texarea? I tried and no luck, it submit the
    information to the database but will not display it inside of the field under
    admin???
    Kane  - fixed!   |119.12.30.xxx |2009-03-11 05:09:43
    Disregard last message, problem fixed!
    Ahsan  - How can i add multiple categories with checkboxes?   |120.50.26.xxx |2009-03-18 05:13:42
    I want edit my registration form and i add some checkboxes which are defined
    some of categories. I already create table fields on my database and do some
    necessary changes but still i don't get those value.

    Please help me to out of
    this problem.
    ankit  - Not working for me   |59.95.170.xxx |2009-03-19 07:54:31
    Guys this code's not working for me..
    I followed all the steps exactly!
    still no change is reflected neither in the front end or the admin back end.
    Im
    using Joomla 1.5.9
    Plz help out.
    ravi salaria  - joomla     |122.173.2.xxx |2009-03-23 04:10:22
    its very good site to know how to joomla works realy but i want to know deeply
    about joomla can you help me
    Chris   |212.123.159.xxx |2009-03-28 08:25:36
    Hi,
    Nice but allas no effect. The loginpage is still the same so is the admin
    users page
    Michael   |145.97.216.xxx |2009-03-29 12:41:30
    Tip:
    don't modify the already excisting fields, because they are used by
    Joomla.

    Example: I wanted to change name into firstname.
    Better:
    name,
    middlename, lastname
    And only change the label of name into firstname.

    great
    tutorial btw
    Vineeth  - Consultant   |86.96.228.xxx |2009-03-31 11:29:49
    I did as you mentioned. But the registration page remains the same without the
    new changes. How can I know where the error is? I am on Joomla 1.5 using a
    template from rockettheme. Please help?
    ARIALDO   |92.104.244.xxx |2009-04-06 13:41:50
    Hi, I noticed, that the changes do not show up, when you use your own template.
    Try one of the basic joomla template (i.e. j purity). If it works, it's possible
    to change the corresponding php-files in your template directory later on as
    well.
    Do you habe any idea for my error message jtableuser::Store Failed?

    Ari
    ARIALDO  - jtableuser::Store Failed     |92.104.244.xxx |2009-04-06 07:18:37
    Thank you for your instruction how to add additional fields to registration. It
    worked out to add the fields. However, when I want to register, I get the
    following message: jtableuser::Store Failed. Please help me!
    Thank you!!!
    Greetings from ZH Switzerland! Ari
    janman  - re: jtableuser::Store Failed   |196.35.158.xxx |2009-04-21 21:48:24
    ARIALDO wrote:
    Thank you for your instruction how to add additional fields to
    registration. It worked out to add the fields. However, when I want
    to register, I get the following message: jtableuser::Store Failed.
    Please help me!
    Thank you!!! Greetings from ZH Switzerland! Ari
    DART  - Store failed.   |Administrator |2009-04-22 05:58:21
    Are you sure you made all the changes correctly? Especially in the user class
    and in the database?
    Santosh  - Very easy     |59.184.37.xxx |2009-05-23 04:30:20
    I do not know ABC of php. But just followed the instructions. and it
    WORKED!!!
    Great!!!!!!!!!!!!!
    Auninda  - You made it really easy!!   |123.49.42.xxx |2009-05-25 11:02:46
    I am really grateful to you for the way you presented the whole thing with clear
    explanations of each step. Thankx a lot man.
    Tovah137   |75.148.27.xxx |2009-06-24 16:46:13
    Followed directions exactly, double and triple checked my input- still receiving
    error: jtableuser::Store Failed

    Please help ASAP!!!!!
    valadonis  - Webmaster     |24.23.15.xxx |2009-09-27 13:26:30
    I have an Everquest guild website (MMORPG) and I wanted to add information to
    the registration form and user list. I had to search a bit and got some vague
    and even bad advice from other places...

    But this is EXACTLY what I needed. I
    followed your instructions step by step and it works perfectly.

    In fact, it has
    inspired me to begin studying and developing custom components for the MMORPG
    community.

    In short... Thank You Very Much!
    DART   |Administrator |2009-09-29 09:35:33
    Good to know we've helped!
    dia   |112.135.207.xxx |2009-11-01 04:29:08
    Thanks really a lot for this code!!!
    Only registered users can write comments!

    3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

    Last Updated ( Thursday, 05 November 2009 )
     

    Sponsors

    Login Form






    Lost Password?
    No account yet? Register

    Buy us a beer!

    If we've helped you, consider buying a beer €3. It will inspire us to keep on giving! Cheers!


    Generated in 0.21541 Seconds