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’ );?>” 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’ );?>” 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’ );?>” 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 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 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 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>
<label for=”email”>
<?php echo JText::_( ‘Email’ ); ?>
</label>
</td>
<td>
<input type=”text” name=”email” id=”email” size=”40″ value=”<?php echo $this->user->get(’email’); ?>” />
</td>
</tr>

<tr>
<td>
<label 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’); ?>” />
</td>
</tr>
<tr>
<td>
<label 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’); ?>” />
</td>
</tr>