PDA

View Full Version : Hooking in Custom Variable on FORUMHOME


d1jsp
08-26-2013, 03:53 PM
Hello,

I'm trying to hook in a custom field from the user table, which is used to generate a different image next to usernames in the active users section at the bottom of the forum home page.

I have read and tried to execute the following article to no avail:
https://vborg.vbsupport.ru/showthread.php?t=228078

On the FORUMHOME template is the following code:
<vb:each from="activeusers" value="loggedin">
<li>{vb:stylevar dirmark}<a class="username" href="{vb:link member, {vb:raw loggedin}}">{vb:raw loggedin.musername}</a>{vb:raw loggedin.invisiblemark}<img src="./images/stars/{vb:raw uinfo.star}" onerror="this.src = 'http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif';" /><!--{vb:raw loggedin.buddymark}-->{vb:raw loggedin.comma}{vb:raw uinfo}</li>
</vb:each>

The code from above that I added in is:
<img src="./images/stars/{vb:raw uinfo.star}" onerror="this.src = 'http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif';" />
Before doing any of this I did try bbuserinfo, but it will just give the same result for every user (the result being the data that belongs to the viewing user). userinfo also does not work.

Here is the plugin I tried making to make the user information available in the FORUMHOME template:
$uinfo = fetch_userinfo($vbulletin->userinfo['userid']);
$templater = vB_Template::create('mytemplate');
$templater->register('uinfo', $uinfo);
$templatevalues['uinfo'] = $templater->render();
vB_Template::preRegister('FORUMHOME', $templatevalues);
I hooked this in at forumdisplay_start, but it seems when I try to print out the uinfo array data it acts as it it doesn't exist.

Does anyone have any suggestions as to what I am doing wrong or if there is an easier way to handle this?

Thanks for looking.

--------------- Added 1377541481 at 1377541481 ---------------

I got it to work. What I did was edit the query found in forum.php to include my custom field in the SELECT statement. Then I was able to use loggedin.star to output the per-user value.
$forumusers = $db->query_read_slave("
SELECT
user.username, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.usergroupid, user.lastvisit, user.star,
session.userid, session.inforum, session.lastactivity, session.badlocation,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
$hook_query_fields
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
$hook_query_joins
WHERE session.lastactivity > $datecut
$hook_query_where
" . iif($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 3, "ORDER BY username ASC") . "
");

--------------- Added 1377543345 at 1377543345 ---------------

Now I'm facing an issue where it works for everyone but for the username of the person viewing the forum.