Sunday, July 17, 2011

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 inJoomla Registration page.

1) Open librariesjoomladatabasetableuser.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 administratorcomponentscom_usersviewsusertmplform.php. Add below code for two fields in registration page.
<tr>
    <td width=”150″>
<label for=”extra1″>
    <?php echo JText::_( ‘extra1′ ); ?>
</label>
</td>
<td>
    <input type=”text” name=”extra1″ id=”extra1″ size=”40″ value=”<?php echo $this->user->get(‘extra1′); ?>” />
</td>
</tr>
<tr>
<td width=”150″>
<label for=”extra2″>
    <?php echo JText::_( ‘extra2′ ); ?>
</label>
</td>
<td>
    <input type=”text” name=”extra2″ id=”extra2″ size=”40″ value=”<?php echo $this->user->get(‘extra2′); ?>” />
</td>
</tr>
4) Open componentscom_userviewsregistertmpldefault.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′ ));?>” 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′ ));?>” maxlength=”50″ /> *
   </td>
</tr>
5) Copy all files from componentscom_userviewsregistertmpl folder and paste it to your custom theme template(default is “rukhmilkway”) directory. ( templates{custom_theme}htmlcom_userregister )
6) For edit profile of user, Copy all files from componentscom_userviewsusertmpl directory and paste it to  templates{custom_theme}htmlcom_useruser. 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 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 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.


[PHP Freelancing India]
:D

0 comments:

Post a Comment

Any Questions or Suggestions ?

About

Professional & Experienced Freelance Developer From India, Technologist, Software Engineer, internet marketer and Open Sources Developer with experience in Finance, Telecoms and the Media. Contact Me for freelancing projects.

Enter your email address:

Delivered by FeedBurner