1
tsol2001
New field in user account
  • 2005/1/17 18:08

  • tsol2001

  • Just popping in

  • Posts: 1

  • Since: 2004/11/24


i want to do a hack of the user account, to add fields like phone number, address and so.

Where should i start looking?
What are the importent files?

Adding the fields to the database is not the problem.

Any hints


regards


Jürgen

2
jansen
Re: New field in user account
  • 2005/1/17 19:35

  • jansen

  • Just popping in

  • Posts: 71

  • Since: 2004/3/9 1


Actually it is not that hard to add fields to the user form, on my website I added some 25 new fields. I found a tutorial at http://www.xoops-doc.org/modules/wfsection02/article.php?articleid=1 so check it out!

3
Cavan
Re: New field in user account
  • 2005/1/19 19:37

  • Cavan

  • Friend of XOOPS

  • Posts: 218

  • Since: 2004/11/28


Are the instructions available in English?

4
jansen
Re: New field in user account
  • 2005/1/19 19:46

  • jansen

  • Just popping in

  • Posts: 71

  • Since: 2004/3/9 1


Unfortunately they are only available in French, but with a little bit of work you could manage to figure the big lines

5
m0nty
Re: New field in user account
  • 2005/1/19 20:12

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


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.

Login

Who's Online

356 user(s) are online (256 user(s) are browsing Support Forums)


Members: 0


Guests: 356


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits