5
Introduction
The purpose of this guide is to explain you how to modify the form of inscription, if you wish to add additional fields.
The example hereafter adds:
- a field Name (name), which already exists in the base, but not in the form
- a field First name (firstname), to entirely create.
For XOOPS 2.0.5 to 2.0.7
Caution:
- follow the indications scrupulously and make the tests progressively.
- take the usual precautions (test locally, safeguard of the site before application of the hack)
Synopsis
1)
Form of recording
include/registerform
2)
Definitions of language
language/...../user.php
3)
Count users
xoops_users
4)
Classify to use
kernel/user.php
5)
Management of the recording
register.php
6)
Information on the member
userinfo.php
7)
Template
system/templates/system_userinfo.html
8)
Modification of the profile by the member
edituser.php
9)
Administration member : form
modules/system/admin/users/userform.php
10)
Administration member: main file
modules/system/admin/users/main.php
11)
Edition, update of the member
modules/system/admin/users/users.php
12)
Definition of language for the admin
modules/system/language/... /admin/users.php
NB: If you want simply to insert an existing field in the table (name for example), only stages 1 and 5 are necessary.
1) Form of recording
File include/registerform
Under the line
$reg_form->addElement(new XoopsFormText(_US_NICKNAME, "uname", 26, 25, #), true);
Add
$reg_form->addElement(new XoopsFormText(_US_NAME, "name", 26, 25, #), true); //true if obligatory field
$reg_form->addElement(new XoopsFormText(_US_FIRSTNAME, "firstname", 26, 25, #)); //e.g. with nonobligatory field
Easy way
To add one * after the name of an obligatory field
$reg_form->addElement(new XoopsFormText(_US_NAME. "*", "name", 26, 25, #), true);
2) Definitions of language
File language/...../user.php
Under the line
define(' _US_NAME', ' Name');
Add
define(' _US_FIRSTNAME', ' Firstname');
Test the posting of the form now.
3) Table xoops_users
Modify the table xoops_user now to add the field firstname varchar(60) after the field name.
4) Class to use
Modify the class to use for the taking into account of the new field firstname
File kernel/user.php
Under the lines
function xoopsuser($id = null)
# initvar('name'>, XOBJ_DTYPE_TXTBOX, null, false, 60);
Add
# initvar('firstname'>, XOBJ_DTYPE_TXTBOX, null, false, 60);
Add the function
function firstname($format="s")
{
return # getvar("firstname>", #);
}
In the function: function insert(&$user, $force = false)
insert the parts in red: (respect here for your new field its position in the table users)
yew (# isnew(>)) {
$sql = sprintf("INSERT INTO %s (uid, uname, name, firstname, email....
...... BEEN WORTH (%u, %s, %s,%s, %s.....
..... # db->quotestring($uname>), # db->quotestring($name>), # db->quotestring($firstname>),
# db->quotestring($email>),....
} else {
$sql = sprintf("UPDATE %s SET uname = %s, name = %s,firstname = %s, email = %s.....
.... # db->quotestring($uname>), # db->quotestring($name>),# db->quotestring($firstname>),
# db->quotestring($email>)....
5) Management of the form of inscription
File register.php
Part puts ' newuser':
Under the line
echo "< input type=' hidden' name=' uname' value='".$myts->makeTboxData4PreviewInForm($uname)."' / > ";
Add
echo "< input type=' hidden' name=' name' value='".$myts->makeTboxData4PreviewInForm($name)."' / > ";
echo "< input type=' hidden' name=' firstname' value='".$myts->makeTboxData4PreviewInForm($firstname)."' / > ";
Part puts ' finish':
Under the line
# setvar('uname'>, #);
Add
# setvar('name'>, #);
# setvar('firstname'>, #);
Now test the recording of a member.
6) Posting of the profile
File userinfo.php
Under the lines
# assign('lang_realname'>, _ US_REALNAME);
# assign('user_realname'>, # getvar('name'>));
Add
# assign('lang_firstname'>, _ US_FIRSTNAME);
# assign('user_firstname'>, # getvar('firstname'>));
7) Template of posting of the profile
File system/templates/system_userinfo.html
While adding
< tr >
< td class="head"><{$lang_firstname}>
< td align="center" class="odd"><{$user_firstname}>
Up to date Metrre the module system
Now test ' See its compte'
8) To publish its account
File edituser.php
In the part
yew (# == ' saveuser') {
Under the line
# setvar('name'>, #);
Add
# setvar('firstname'>, #);
In the part
yew (# == ' editprofile') {
Under the lines
$name_text = new XoopsFormText(_US_REALNAME, ' name', 30, 60, # getvar('name'>, ' E'));$form->addElement($name_text);
Add
$firstname_text = new XoopsFormText(_US_FIRSTNAME, ' firstname', 30, 60, # getvar('firstname'>, ' E'));$form->addElement($firstname_text);
Now test ' To publish its compte'
9) Administration member
File modules/system/admin/users/userform.php
At the beginning, under the line
$name_text = new XoopsFormText(_AM_NAME, "name", 30, 60, #);
Add
$firstname_text = new XoopsFormText(_AM_FIRSTNAME, "firstname", 30, 60, #);
Towards the end, under the line
# addelement($name_text>);
Add
# addelement($firstname_text>);
10) Administration member: main file
File modules/system/admin/users/main.php
Modify the call with the function updateUser
updateuser($uid, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #);
11) Administration : up to date édition/mise of the member
File modules/system/admin/users/users.php
function modifyuser($user)
Under the line
$name_value = # getvar("name>", "E");
Add
$firstname_value = # getvar("firstname>", "E");
function updateUser
function updateuser($uid, #, #,#, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #)
then under the line
# setvar("name>", #);
Add
# setvar("firstname>", #);
12) Definition of language for the administration
File modules/system/language/... /admin/users.php
define("_AM_FIRSTNAME", "Prénom");
Now test ' ' Editer/effacer of the membres'
To conclude
From the example above, you will be able to personalize this form of inscription differently, but you must for celà have a minimum of knowledge on the various classes of form of xoops, the instructions php, the requests sql.