PDA

View Full Version : Users online for mods/admins only


Sharron
12-11-2008, 11:40 PM
We runa very busy board and the users online is in excess of 1,000 much of the time. This has an effect on performance and since the users online is not essential to members they don't need it so it's on of the things we are looking to remove from members.

However, the staff of the board do need it.

I can hide the display of the users online from members easily enough such that it shows only to mods and admins but of course the query still runs and so this offers no performance benefit.

So, I need to be able to set it so that the query to get the users online only actually runs when a mod or admin opens the forum index, and not run at all when a normal member opens the page which isn't a template job.

Anybody have any ideas where and how this would be acheived?

Lynne
12-12-2008, 02:09 AM
Here's the line you want to change in the code:
// ### LOGGED IN USERS #################################################
$activeusers = '';
if (($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 2 OR ($vbulletin->options['displayloggedin'] > 2 AND $vbulletin->userinfo['userid'])) AND !$show['search_engine'])
{

You can just turn the option off in vboptions > forum home page > display logged in users (displayloggedin will equal 0) and then add into the first condition "OR is_member_of($bbuserinfo,5,6,7)" - 5,6,7 being the mods, admins, and supermods. You can modify the usergroups as you want.

Sharron
12-12-2008, 08:07 AM
Thank you.

I found the line of code but no matter where I put the new OR clause it makes no difference - if display is turned off in forum home page options then nobody sees the who's online, if it turned on then everyone sees the who's online.

I confess it is early in the morning for me and I've had 3 hours sleep so I may be missing something but any help would be much appreciatted.

Mosh
12-12-2008, 08:17 AM
Thank you.

I found the line of code but no matter where I put the new OR clause it makes no difference - if display is turned off in forum home page options then nobody sees the who's online, if it turned on then everyone sees the who's online.

I confess it is early in the morning for me and I've had 3 hours sleep so I may be missing something but any help would be much appreciatted.
Try changing the OR to an AND, putting it at the end of the conditional, and leave the display logged in users set to on, that should force $show['loggedinusers'] to be false and not run the query.

i.e

// ### LOGGED IN USERS #################################################
$activeusers = '';
if (($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 2 OR ($vbulletin->options['displayloggedin'] > 2 AND $vbulletin->userinfo['userid'])) AND !$show['search_engine'] AND is_member_of($bbuserinfo,5,6,7))
{

Sharron
12-12-2008, 08:38 AM
It's still the same.

I think it may be because I am not sure where to actually put the new bit though to be honest. I've tried it everywhere. If it's here if (($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 2 AND is_member_of($bbuserinfo,5,6,7) OR ($vbulletin->options['displayloggedin'] > 2 AND $vbulletin->userinfo['userid'])) AND !$show['search_engine']) the page just follows the vboptions setting - either all see it or no-one sees it.

put it here if (($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 2 OR ($vbulletin->options['displayloggedin'] > 2 AND $vbulletin->userinfo['userid']) AND is_member_of($bbuserinfo,5,6,7)) AND !$show['search_engine']) the same

here if (($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 2 OR ($vbulletin->options['displayloggedin'] > 2 AND $vbulletin->userinfo['userid'])) AND is_member_of($bbuserinfo,5,6,7) AND !$show['search_engine']) and nobody sees it at all even if it is switched on in options

I must be doing something wrong some where.

Mosh
12-12-2008, 09:14 AM
OK, this is tested and working:

Like Lynne said - "You can just turn the option off in vboptions > forum home page > display logged in users (displayloggedin will equal 0)"

Then replace:
// ### LOGGED IN USERS #################################################
$activeusers = '';
if (($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 2 OR ($vbulletin->options['displayloggedin'] > 2 AND $vbulletin->userinfo['userid'])) AND !$show['search_engine'])
{


with:

// ### LOGGED IN USERS #################################################
$activeusers = '';
if (($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 2 OR ($vbulletin->options['displayloggedin'] > 2 AND $vbulletin->userinfo['userid']) OR is_member_of($vbulletin->userinfo,5,6,7)) AND !$show['search_engine'])
{

Lynne
12-12-2008, 02:48 PM
Mosh posted the correct code (I should have spelled it out, sorry). But, you need to make sure you also set that option to NO (which Mosh also restated in his post).

Sharron
12-12-2008, 02:54 PM
It worked beautifully thank you :) I can't have been getting it in the right place but once I copied the code as Mosh typed it it worked.

Thank you for your help both of you.