 |
I am going to do a step by step on how to create extended registration fields. This involves editing of core Joomla files, so it is recommend that you keep a back up of the files before editing them. |
|
|
|
|
Step 1.
First add 2 columns to MYSQL and I used this code:
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;
Verfied the columns existed.
Step 2: I use dreamweaver for modification to php code so I will list it the way I did it. I modified 3 files:
libraries/joomla/database/table/user.php
Find this part of the code from file above and added what is business and phone: (below) |
|
var $name = null;
/**
* The login name
*
* @var string
*/
var $business = null;
var $phone = null;
var $username = null;
/**
* The email
*
* @var string
*/
var $email = null;
|
|
components/com_user/views/register/tmpl/default.php
Find this part of the code from file above and added what is business and phone: (below) |
|
<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">: </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>
|
|
components/com_user/views/user/tmpl/form.php
Find this part of the code from file above and added what is business and phone: (below) |
|
<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>
|
|
Now to show the result in the backend area
Edit the page which displays the users in the backend: administrator\components\com_users\views\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>
|
|
| Add your fields to it. DO NOT delete anythng from this file |
|
<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">
<l;abel 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>
|
|
| Finally you have added custom fields to the default Joomla Registration |
Pingback: Tweets that mention Customize registration page Joomla 1.5 | The Old Skool Blog -- Topsy.com
Pingback: Customizing your Online Registration Forms | Articlewrap.com