View Full Version : User Profile Field Question
sunilvarma
13 Aug 2007, 12:57
I created a user profile field and want to use it in the FORUMHOME template.
To show it in the postbit I used $post[field6] and it works. But if I use this in the FORUMHOME template, it doesn't work.
I know I'm missing something here. Can someone help me with this?
nico_swd
13 Aug 2007, 13:41
Try
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
sunilvarma
13 Aug 2007, 13:58
nope, that didn't work.
Opserty
13 Aug 2007, 14:15
$bbuserinfo['field6']
sunilvarma
13 Aug 2007, 14:22
this shows only the info for the logged in user. but i want to work i a slightly different way.
in the who's online list i want to show the field6 of each loggedin user against their username.
sunilvarma
15 Aug 2007, 14:42
anyone?
Opserty
15 Aug 2007, 14:46
You'd have to write a plugin then since I don't think userfields are fetched in the "Whats Going On" but. If you know the PHP side of vBulletin then you'd need to find the correct hook location (the one inside the user display loop) and use $userinfo = fetch_userinfo($userid) to fetch the info for the specified user. Then use $userinfo['field6'] to access the data.
sunilvarma
15 Aug 2007, 17:46
well, unfortunately i am not that good at PHP. so could you elaborate further?
Thanks
Opserty
15 Aug 2007, 18:12
Add a new plugin
With hook location forumhome_loggedinuser
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
The in Style Manger Go to Edit Templates -> Forum Home Templates -> forumhome_loggeninuser
Add $online_userinfo[field6] to the end of it.
Don't know if that is the most efficient way to do it, but it works. Hopefully :)
sunilvarma
15 Aug 2007, 19:11
thanks a lot Opserty. it worked.
I think that method will query the database for each user on the page.
Try this ;
Create a plugin using the "online_query" hook - with this in it ;
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
You should then have the userfields in the $userinfo array ( e.g. $userinfo['field6'] );
I think that method will query the database for each user on the page.
It does. :down:
e.g. $userinfo['field6'] );
Paul - can't get yours to work, but this is not helped by me not understanding your method exactly! One thing is I can't enter the single quotes you use (around field6). And it seems to only affect the WOL page, which just returns a database error.
Any advances?
WhaLberg
08 Oct 2007, 15:19
Please note that do not use ' (single quote) in templates.
Indeed not.
I suspect the solution is to add a bit to the query in index.php, but I'm not having much luck so far.
Michael Biddle
08 Oct 2007, 19:21
Paul - can't get yours to work, but this is not helped by me not understanding your method exactly! One thing is I can't enter the single quotes you use (around field6). And it seems to only affect the WOL page, which just returns a database error.
Any advances?
Paul is right. The hook is already inside of the query so you are just adding more things for it to select out of the database for instance, fielf6.
In your template you should then use $userinfo[field6]
Paul is right. The hook is already inside of the query so you are just adding more things for it to select out of the database for instance, fielf6.
In your template you should then use $userinfo[field6]
If I reproduce what Paul suggests, then using $userinfo[field6] in the template forumhome_loggedinuser has no effect (what we're trying to do is get stuff to show in the list of users in "What's going on".
Furthermore, the WOL page (online.php, which we are not trying to modify) shows:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
--------------- Added at 10:26 ---------------
I now have this working, but it would be great if an SQL person could check my code for me.
In index.php, there is the query in "logged in users" that pulls the stuff up for WGO. I have added the stuff in red:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
I have also added the line in red just below:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
And I can now use $loggedin[field6] in forumhome_loggedinuser. I know this is poor because it modifies php, but in the absence of a hook in that query I can't see another way.
Michael Biddle
09 Oct 2007, 19:25
Request a hook location at vb.com :D
As I see it, it would require three...
Michael Biddle
09 Oct 2007, 21:41
request 3 then.
vBulletin® v3.6.12, Copyright ©2000-2009, Jelsoft Enterprises Ltd.