Site icon Nabtron

Add custom field for user data ( joomla 1.0 tested )

In this tutorial we will discuss how to add new / custom fields to the joomla! user data like age, address etc.

Once we have added the custom user data fields to the core, we can show them in registration page and accounts detail page etc.

This have been tested on Joomla 1.0.

1. Add custom fields to joomla database

First step is to add the custom fields that we want for the user data to be added to joomla database.

Goto joomla database > jos_users > simply add new custom field in the table with any name (e.g: address)

2. Edit joomla.php

Now we will be adding the custom fields for the user data to the joomla.php in the includes folder.

Goto > joomla directory > includes > joomla.php

Search for this line:

class mosUser extends mosDBTable {

add this after that line:

/** @var our new variable*/

var $our-variable-name = null;

3. Edit user.php

Now we need to edit the user.php file with our new custom user data fields.

Goto > joomla directory > com_user > user.php

look for:

$row->email

this will be found twice in 2 lines (total four times)

simply copy those two lines and paste below it with our variable name.

e.g:

$row->email = trim( $row->email );

$row->address = trim( $row->address );

This way the custom fields will be added to the user.php file

4. Edit user.html.php

Last step is to add the new input fields to the form that submits the data about them.

Goto > joomla directory > com_user > user.html.php

and add new custom input field according to the design.

5. Edit admin.users.html.php

Do the same step as above for the admin.users.html.php to show user data in admin panel.

Exit mobile version