1
jordi_rc
General procedure to add new fields to user profile
  • 2006/11/20 10:57

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


Hello!

I am trying to add 2 fields to user profile.
I tried to do as m0nty did with his photo hack, modifying some files.
I didn't modified all the files that m0nty did, as I only want my hack to insert 2 new fields, with no special functions associated.

I found the files to modify are these:

To add a new field to user profile:
----
Quote:


root/edituser.php
root/userinfo.php
root/register.php

root/include/registerform.php

root/kernel/user.php

root/language/english/user.php
root/language/english/global.php

root/modules/system/templates/system_userinfo.html



------------------------

To make possible modify these fields form admin panel:
----
Quote:


root/modules/system/admin/users/main.php
root/modules/system/admin/users/users.php
root/modules/system/admin/users/userform.php
root/modules/system/language/english/admin/users.php




But I did some mistake, possibly at kernel/user.php and the hack didn't work.

The fields are 2: credits (a number) and avatar3d (an url).
I added them to my xoops_users table.

I have 2 questions:

1) How to add these fields properly, specially at kernel/user.php ?

2) Have I forgotten to modify some important file ?

Please m0nty or anyone help me with this, let's see if we could find a general way to hack and have extra fields added.

Jordi.
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

2
jordi_rc
Re: General procedure to add new fields to user profile
  • 2006/11/20 17:42

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


No one knows?

Jordi
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

3
davidl2
Re: General procedure to add new fields to user profile
  • 2006/11/20 17:47

  • davidl2

  • XOOPS is my life!

  • Posts: 4843

  • Since: 2003/5/26


You'll have to give a little more time then just a few hours... remember - some of us do work, and others may be asleep

If you've searched, you'll see that Monty has advised using Formulize to replace his hack... I would suggest searching on this would be a good start.

4
jordi_rc
Re: General procedure to add new fields to user profile
  • 2006/11/20 18:20

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


Sorry davidl2,

I think I've been to impatient...I'm sorry.

As I implemented m0nty hack and modified it a lot, I am reticent to substitute it with Formulize.

But I will look to see if I can do it with Formulize the adding of those fields.

Some time ago I tried to install Formulize and didn't worked in my pc. I will try the new version.

In the other hand, if someone knows my questions please answer or give any advice...

I also thought in creating a module of credits and another relative to 3d avatars, but I didn't created any module so it can take me a lot to do.

Anyway I will try all ways to do this in these days.
If someone wants to stop my suffering helping me in an easy way, I will appreciate.

Sorry for my impatience,


Jordi


(By the way, davidl2 do you know when xoopsdev will be online again? I want to post my Buddyfriends bugfixed. I tried to locate the previous developers but they don't answer my emails. That was many weeks ago. I just want to post the bugfixed and improved Buddyfriends module I bugfixed so they can continue developing. Where should I post it?)
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

5
davidl2
Re: General procedure to add new fields to user profile
  • 2006/11/20 18:31

  • davidl2

  • XOOPS is my life!

  • Posts: 4843

  • Since: 2003/5/26


hhttp://dev.xoops.org/ is online?

6
jordi_rc
Re: General procedure to add new fields to user profile
  • 2006/11/20 18:47

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


Oh, it seems it online now, thanks.

I checked it yesterday and this morning and I saw a message that said they "will be back in November".

I downloaded Formulize and saw it, but it seems it is great for adding information or questions files, but it is not aimed to add files like those I want.

avatar3d will be to choose a vrml or x3d file for 3d avatar, so I will need to make a page to choose from many of them, like the 2d avatars of xoops, and allow members to paste a url to a custom avatar.

And credits will work like virtual money, or points, based on member contributions. I also though in cloning TopMembers module for this.

I will try to hack it again or do a module approach.

Thanks davidl2.

Jordi
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

7
m0nty
Re: General procedure to add new fields to user profile
  • 2006/11/20 20:00

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


as you didn't actually say why it didn't work, it's hard to diagnose..

but a likely candidate is in kernel/user.php

find this (around line 625 in my hacked version) line numbers will be different in unhacked XOOPS version.

// RMV-NOTIFY
        //  m0nty added 16 fields > user_photo, user_birth, user_love, user_nolove, user_music1, user_music2, user_music3, user_music4, user_music5, user_film1, user_film2, user_film3, user_film4, user_film5, user_gender, user_starsign
        
if ($user->isNew()) {
            
$uid $this->db->genId($this->db->prefix('users').'_uid_seq');
            
$sql sprintf("INSERT INTO %s (uid, uname, name, email, url, user_avatar, user_photo, user_regdate, user_icq, user_from, user_sig, user_viewemail, actkey, user_aim, user_yim, user_msnm, pass, posts, attachsig, rank, level, theme, timezone_offset, last_login, umode, uorder, notify_method, notify_mode, user_occ, bio, user_intrest, user_mailok, user_birth, user_love, user_nolove, user_music1, user_music2, user_music3, user_music4, user_music5, user_film1, user_film2, user_film3, user_film4, user_film5, user_gender, user_starsign) VALUES (%u, %s, %s, %s, %s, %s, %s, %u, %s, %s, %s, %u, %s, %s, %s, %s, %s, %u, %u, %u, %u, %s, %.2f, %u, %s, %u, %u, %u, %s, %s, %s, %u, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"$this->db->prefix('users'), $uid$this->db->quoteString($uname), $this->db->quoteString($name), $this->db->quoteString($email), $this->db->quoteString($url), $this->db->quoteString($user_avatar), $this->db->quoteString($user_photo), time(), $this->db->quoteString($user_icq), $this->db->quoteString($user_from), $this->db->quoteString($user_sig), $user_viewemail$this->db->quoteString($actkey), $this->db->quoteString($user_aim), $this->db->quoteString($user_yim), $this->db->quoteString($user_msnm), $this->db->quoteString($pass), $posts$attachsig$rank$level$this->db->quoteString($theme), $timezone_offset0$this->db->quoteString($umode), $uorder$notify_method$notify_mode$this->db->quoteString($user_occ), $this->db->quoteString($bio), $this->db->quoteString($user_intrest), $user_mailok$this->db->quoteString($user_birth), $this->db->quoteString($user_love), $this->db->quoteString($user_nolove), $this->db->quoteString($user_music1), $this->db->quoteString($user_music2), $this->db->quoteString($user_music3), $this->db->quoteString($user_music4), $this->db->quoteString($user_music5), $this->db->quoteString($user_film1), $this->db->quoteString($user_film2), $this->db->quoteString($user_film3), $this->db->quoteString($user_film4), $this->db->quoteString($user_film5), $this->db->quoteString($user_gender), $this->db->quoteString($user_starsign));
        } else {
            
$sql sprintf("UPDATE %s SET uname = %s, name = %s, email = %s, url = %s, user_avatar = %s, user_photo = %s, user_icq = %s, user_from = %s, user_sig = %s, user_viewemail = %u, user_aim = %s, user_yim = %s, user_msnm = %s, posts = %d,  pass = %s, attachsig = %u, rank = %u, level= %u, theme = %s, timezone_offset = %.2f, umode = %s, last_login = %u, uorder = %u, notify_method = %u, notify_mode = %u, user_occ = %s, bio = %s, user_intrest = %s, user_mailok = %u, user_birth = %s, user_love = %s, user_nolove = %s, user_music1 = %s, user_music2 = %s, user_music3 = %s, user_music4 = %s, user_music5 = %s, user_film1 = %s, user_film2 = %s, user_film3 = %s, user_film4 = %s, user_film5 = %s, user_gender = %s, user_starsign = %s WHERE uid = %u"$this->db->prefix('users'), $this->db->quoteString($uname), $this->db->quoteString($name), $this->db->quoteString($email), $this->db->quoteString($url), $this->db->quoteString($user_avatar), $this->db->quoteString($user_photo), $this->db->quoteString($user_icq), $this->db->quoteString($user_from), $this->db->quoteString($user_sig), $user_viewemail$this->db->quoteString($user_aim), $this->db->quoteString($user_yim), $this->db->quoteString($user_msnm), $posts$this->db->quoteString($pass), $attachsig$rank$level$this->db->quoteString($theme), $timezone_offset$this->db->quoteString($umode), $last_login$uorder$notify_method$notify_mode$this->db->quoteString($user_occ), $this->db->quoteString($bio), $this->db->quoteString($user_intrest), $user_mailok$this->db->quoteString($user_birth), $this->db->quoteString($user_love), $this->db->quoteString($user_nolove), $this->db->quoteString($user_music1), $this->db->quoteString($user_music2), $this->db->quoteString($user_music3), $this->db->quoteString($user_music4), $this->db->quoteString($user_music5), $this->db->quoteString($user_film1), $this->db->quoteString($user_film2), $this->db->quoteString($user_film3), $this->db->quoteString($user_film4), $this->db->quoteString($user_film5), $this->db->quoteString($user_gender), $this->db->quoteString($user_starsign), $uid);


it's likely that you may have not added the new fields correctly here. also make sure you also add an exta %s for every new field you add.

as for formulize, you also need the registration codes hack aswell you can find that at http://www.freeformsolutions.ca/formulize/

8
jordi_rc
Re: General procedure to add new fields to user profile
  • 2006/11/20 20:37

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


Hi m0nty,

I think it is kernel, yes.
I am sure that I didn't modified that lines, I would remmember.

Thanks m0nty I think that is the exact line why it didn't worked. I will try to do it, and tell if is that.

Your hack was very nice, it fits my needs allright.

Do you know if with formulize one can do the following:

- Add avatar selection on new users register ( I hacked that ).

- Access custom fields from php functions easilly ( with getVar)

- Add new fields with their propper name to xoops_users table

It seems that formulize is great for asking new fields just to show them but if someone tested it, maybe can tell us if the new fields can be accessed and manipulated easilly from php programming as those that are in xoops_user table that have comprehensible names.

Thanks again m0nty, you are top of the best.

Jordi.
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

9
jordi_rc
Re: General procedure to add new fields to user profile
  • 2006/11/21 19:31

  • jordi_rc

  • Not too shy to talk

  • Posts: 114

  • Since: 2006/8/21


Hi m0nty I found that the error was in the %s so now it works OK!!

Thanks a lot!

I used %s for avatar3d and %u for credits, and works OK.

I suppose %s is for string and %u for number? What is %d for??

Am I right?

Jordi
"Battles are fought by those with the courage to believe. They are won by those who find the heart to share." -MANOWAR

10
iHackCode
Re: General procedure to add new fields to user profile

Quote:

jordi_rc wrote:
I used %s for avatar3d and %u for credits, and works OK.

I suppose %s is for string and %u for number? What is %d for??

Am I right?

Jordi


That Is Correct.

PHP.Net Manual: sprintf (Quite A Bit Of Info.)
CBB / LatestNews / Publisher / XM-Spotlight

(ノ◕ヮ◕)ノ*:・゚✧

Login

Who's Online

330 user(s) are online (239 user(s) are browsing Support Forums)


Members: 0


Guests: 330


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