PDA

View Full Version : Add profile fields in the stats section (Forumhome)


Bioman2k
09-23-2012, 10:27 AM
Hello,

In the forumhome, we have by default a row like that :
"Welcome to our new member, [NAME]"

I added new custom profile fields and I would like add these after to be more accurate.
"Welcome to our new member, [NAME], [Field1] - [Field2] [Field3] - [Field4]"

How can I do that modification ?
Thank you in advance.

Have a nice day,

kh99
09-23-2012, 12:42 PM
The username and id of the newest user is already available, but the other fields aren't, so you'd have to look them up. You could use a plugin on hook forumhome_complete to look up the fields for the user with id $newuserinfo['userid'], and either add them to the $newuserinfo array or preRegister a new variable to the FORUMHOME template. Then of course you'd need to edit the FORUMHOME template to display the fields.

Bioman2k
09-23-2012, 12:52 PM
Ok I understand what you mean but i'm novice in PHP.
Could you help me please ?

kh99
09-23-2012, 01:04 PM
OK, try this: create a new plugin using hook forumhome_complete and this code:

if (is_array($newuserinfo))
{
$newuserinfo = array_merge($newuserinfo, fetch_userinfo($newuserinfo['newuserid']));
}


Then edit the FORUMHOME template and find welcome_to_our_newest_member_x (which is the existing phrase), and add {vb:var newuserinfo.fieldX} (once for each field) where you want to add the new fields.

Bioman2k
09-23-2012, 01:24 PM
Thank you for your help.

I've done everything but I have the following error in forumhome and the welcome raw in the footer disappears :

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in [path]/forum.php(787) : eval()'d code on line 3

Any idea ?

kh99
09-23-2012, 08:34 PM
Oh, sorry, I guess it should be
if (is_array($newuserinfo) AND $newuserinfo['userid'] > 0)
{
$newuserinfo = array_merge($newuserinfo, fetch_userinfo($newuserinfo['userid']));
}


and sorry it took so long to get back to you.

Bioman2k
09-23-2012, 09:05 PM
Thank you for all your help.

Your new plugin code hasn't error but I can't see my fields.
You'll see in the attached files the result.

In FORUMHOME, I have put this code :

<p>{vb:rawphrase welcome_to_our_newest_member_x, {vb:link member, {vb:raw newuserinfo}}, {vb:raw newuserinfo.username} {vb:var newuserinfo.field12} {vb:var newuserinfo.field14} {vb:var newuserinfo.field11} {vb:var newuserinfo.field15}}</p>

Thank you.

kh99
09-23-2012, 09:26 PM
I think the problem is that you have the new fields inside the phrase tag, as phrase parameters. You could actually do that if you wanted, but you'd have to edit the phrase and add {3}, {4}, {5} where you want the new fields to show up.

But the easiest thing to do would just be to move them outside the phrase curly tag like:

<p>{vb:rawphrase welcome_to_our_newest_member_x, {vb:link member, {vb:raw newuserinfo}}, {vb:raw newuserinfo.username}} {vb:var newuserinfo.field12} {vb:var newuserinfo.field14} {vb:var newuserinfo.field11} {vb:var newuserinfo.field15}</p>

Bioman2k
09-24-2012, 06:35 AM
It works like a charm !
Thank you so much for all your help.

Have a nice day.