View Full Version : Who's Online Additions
UberMensch
12-12-2007, 09:22 PM
I've got a few custom pages floating around my forum, and I'd like to have them appear properly in the Who's Online (online.php) list.
Editing the functions_online.php is too easy, I'd much rather do it the proper way and use plugins (plus my edits won't be deleted the moment a vBulletin update overwrites the file).
I've done very little work with plugins, but I'm quite confident with php. How would I add custom actions using plugins for the Who's Online list?
TigerWare
12-13-2007, 05:56 PM
Go back to looking at the fuctions_online.php (construct_online_bit function) and in the big case statement (default handler) you will ind the following "hook":
($hook = vBulletinHook::fetch_hook('online_location_unknown ')) ? eval($hook) : false;
If I'm not mistaken you could create a plugin at that location to insert additional criteria for your own custom pages.
UberMensch
12-13-2007, 09:25 PM
I've tried that, but with each hook I received a php error stating that the "case" was unexpected.
TigerWare
12-14-2007, 09:17 AM
Ok. Trying to get a handle on how you are coding it.
Here's the default case where the hook sits...
default:
$handled = false;
($hook = vBulletinHook::fetch_hook('online_location_unknown ')) ? eval($hook) : false;
I take it by your reply (and the error) that you are simply adding a 'case' in your plugin, like this:-
case 'something':
// etc...
So logically this would be interpreted like this:-
default:
$handled = false;
case 'something':
// etc...
This would be incorrect syntax, and yes, your custom case would not be expected at that location. I think to cure that you would need to expand the plugin code to a full switch statement, or use an if...then construct.
Hows that looking, or have I missed something?
UberMensch
12-14-2007, 09:23 AM
Yep that's exactly what I was doing.
I've also tried a number of if statements too, none of which did anything (literally ;))
TigerWare
12-14-2007, 04:43 PM
Ok,
How about this.
Hook location: online_location_process
if ($filename == 'yourfile.php')
{
$userinfo['activity'] = 'yourtitle';
}
and
Hook location: online_location_unknown
if ($userinfo['activity'] == 'yourtitle')
{
$userinfo['action'] = 'Viewing Your Page';
$userinfo['where'] = '<a href="./yourfile.php?' . $vbulletin->session->vars['sessionurl'] . '">Your Page</a>';
$handled = true;
}
Might need a little tinkering with the bits in red, but I think that should work.
UberMensch
12-14-2007, 07:35 PM
That worked PERFECTLY! Thanks very, VERY much! :)
TigerWare
12-14-2007, 07:45 PM
Excellent ! :up:
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.