article

Thursday, April 21, 2011

Joomla - add extra fields in joomla registration

Joomla - add extra fields in joomla registration

LIST OF FILES NEED TO EDIT

1. libraries\joomla\database\table\user.php
add two extra fields like phone and website, let’s these fields as optional
put the follow lines before above lines or near line 116

var $params = null;

var $phone = null;
var $website = null;
var $address = null;
/**
* @param database A database connector object
*/
function __construct( &$db )
{
2. add alter your user table
ALTER TABLE jos_users ADD phone varchar(255) DEFAULT '' AFTER password;
ALTER TABLE jos_users ADD website varchar(255) DEFAULT '' AFTER phone;


3. G
o to administrator\components\com_users\views\user\tmpl
open file form.php and put the following lines after line 132 … just add as new row in table




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

4. Goto administrator->site->User Manager




















5. front end registration
components\com_user\views\register\tmpl\default.php for edit


<tr>

<td 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->escape($this->user->get( 'phone' ));?>" class="inputbox" maxlength="50" /> *
</td>
</tr>
<tr>
<td height="40">
<label id="websitemsg" for="website">
<?php echo JText::_( 'Website' ); ?>:
</label>
</td>
<td>
<input type="text" name="website" id="website" size="40" value="<?php echo $this->escape($this->user->get( 'website' ));?>" class="inputbox" maxlength="50" /> *
</td>
</tr>






Copy that default.php file from components\com_user\views\register\tmpl and now go to your current template folder. copy all the php files from components\com_user\views\register\tmpl to templates\{your custom template name here}\html\com_user\register

Related Post