Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

Add extra fields in joomla registration page

Hello Friends,
 
Are you looking for adding extra fields in Joomla registration page ? Yesterday i was working with Joomla and wanted to add extra fields in registration page. For this i need to change the core file and that is the last solution as client needs to add two extra fields in registration page at any cost. Here i am showing you the step by step way to add an extra field in Joomla Registration page.
 
1) Open libraries\joomla\database\table\user.php file.
Find: 
function __construct( &$db )
 
Replace:
function __construct( &$db )
var $extra1 = null;
var $extra2 = null;
 
2) Now add this fields in database using below SQL query.
ALTER TABLE jos_users ADD extra1 varchar(255);
ALTER TABLE jos_users ADD extra2 varchar(255);
 
3) Open administrator\components\com_users\views\user\tmpl\form.php. Add below code for two fields in registration page.
<tr>
    <td width="150" class="key">
<label for="extra1">
    <?php echo JText::_( 'extra1' ); ?>
</label>
</td>
<td>
    <input type="text" name="extra1" id="extra1" class="inputbox" size="40" value="<?php echo $this->user->get('extra1'); ?>" />
</td>
</tr>
<tr>
<td width="150" class="key">
<label for="extra2">
    <?php echo JText::_( 'extra2' ); ?>
</label>
</td>
<td>
    <input type="text" name="extra2" id="extra2" class="inputbox" size="40" value="<?php echo $this->user->get('extra2'); ?>" />
</td>
</tr>
 
4) Open components\com_user\views\register\tmpl\default.php , Add below code where you want to show extra fields.
<tr>
  <td height="40">
      <label id="extra1msg" for="extra1">
         <?php echo JText::_( 'extra1' ); ?>:
      </label>
</td>
   <td>
       <input type="text" name="extra1" id="extra1" size="40" value="<?php echo $this->escape($this->user->get( 'extra1' ));?>" class="txtbox" maxlength="50" /> *
   </td>
</tr>
<tr>
   <td height="40">
      <label id="extra2msg" for="extra2">
         <?php echo JText::_( 'extra2' ); ?>:
      </label>
  </td>
  <td>
       <input type="text" name="extra2" id="extra2" size="40" value="<?php echo $this->escape($this->user->get( 'extra2' ));?>" class="txtbox" maxlength="50" /> *
   </td>
</tr>
 
 
5) Copy all files from components\com_user\views\register\tmpl folder and paste it to your custom theme template(default is "rukhmilkway") directory. ( templates\{custom_theme}\html\com_user\register )
 
6) For edit profile of user, Copy all files from components\com_user\views\user\tmpl directory and paste it to  templates\{custom_theme}\html\com_user\user. Now open form.php file and add below code for two extra fields.
<tr>
    <td width="120">
        <label for="extra1">
            <?php echo JText::_( 'extra1' ); ?>:
        </label>
    </td>
    <td>
        <input class="txtbox" type="text" id="extra1" name="extra1" value="<?php echo $this->escape($this->user->get('extra1'));?>" size="40" />
    </td>
</tr>
<tr>
    <td width="120">
        <label for="extra2">
            <?php echo JText::_( 'extra2' ); ?>:
        </label>
    </td>
    <td>
        <input class="txtbox" type="text" id="extra2" name="extra2" value="<?php echo $this->escape($this->user->get('extra2'));?>" size="40" />
    </td>
</tr>
 
Thats it.
If you find any problem in this than let me know by comment.
Share:

4 Comments

  • ono

    Hello, first, thanks a lot for your article, its great. second, how can i prevent same user input (exp. social number) like username?
    sorry for my bad english 🙂

  • ono

    Hello, first, thanks a lot for your article, its great. second, how can i prevent same user input (exp. social number) like username?
    sorry for my bad english 🙂

  • Rachel appesat…

    […]Add extra fields in joomla registration page | Programming Facts -PHP Freelancer-Indian Freelancer[…]…

  • chevrolet cruze…

    […]Add extra fields in joomla registration page | Programming Facts -PHP Freelancer-Indian Freelancer[…]…

Leave a Reply

Your email address will not be published.