Let me try it and I ll get back to you in a bit
--------------- Added [DATE]1345809644[/DATE] at [TIME]1345809644[/TIME] ---------------
This is way too advanced for me.
I went to add new plugin and chose "showthread_loggedinuser and put;
$viewing_users[] = $loggedin['userid'];
in the PHP code
Saved it.
Then if I did all that right, I m not too sure what you mean by "Then you need to do a query, in another plugin using hook showthread_complete:"
Quote:
Originally Posted by kh99
Here's one way you might be able to do it: You would need to turn on "Show Users Browsing Thread" in the adminCP options, then create a plugin using hook showthread_loggedinuser and code like this:
Code:
$viewing_users[] = $loggedin['userid'];
Then you need to do a query, in another plugin using hook showthread_complete:
Code:
if (is_array($viewing_users) AND count($viewing_users))
{
$field = 'fieldX'; // change X to your actual field #
$results = $vbulletin->db->query_slave("SELECT $field, count(*) AS num FROM " . TABLE_PREFIX . "userfield WHERE userid IN (" . implode(',', $viewing_users) . ") GROUP BY $field");
while ($row = $vbulletin->db->fetch_array($results))
{
$fruit_viewing[$row[$field]] = $row['num'];
}
}
// If you don't want to actually display the "users browsing", you could uncomment this:
// $show['activeusers'] = false;
Then in showthread where you want it to appear, something like:
Code:
<vb:each from="fruit_viewing" key="fruit" value="num">
{vb:raw fruit}: {vb:raw num}
</vb:each>
BTW, I haven't actually tried this.
|