1.5 Registration page
Warning: Joomla Hack! The following code involves modifying the core Joomla code. This has intrinisc drawbacks, i.e. any time you upgrade you'll have to redo the code, or lose this functionalityMake sure you take backups before you do this change!
The Joomla Registration page usually contains enough information for most website. Users who want enhanced user information, typically go for Community Builder which allows extensive user registration fields. However, it is entirely possible to create additional registration fields without installing any components, by modifying a few lines in the Joomla core code. Here's how to do it. In this example, we will be adding Business and Phone to the user registration field, however you can modify the example to add any fields you want to.
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/
var $name = null;
/**
* The login name
*
* @var string
*/
/**
* 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
*
*
*
3. Modify the view of the users list: components/com_user/views/ user/tmpl/form.php
:
:
4. Edit the page which displays the users in the backend: administrator\components\com_users\views\user\tmpl\form.php
That's it! You now have a couple of additional fields in the users table, and more information available to use. Thanks goes to jtullous from the Joomla Forums who supplied the code.
Make sure you take backups before you do this change!
No comments:
Post a Comment