Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Suppress Administrator Online
Avatar
B. E. Johnson
Member
Free Members
sp_UserOfflineSmall Offline
Sep 16, 2013 - 12:25 am

Is there any way to suppress the display of Administrators' usernames appearing in the Curretntly Online and Currently Browsing This Page fields, without enabling Allow Members to Hide Their Online Status?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 16, 2013 - 12:50 am

not directly...  but there is a filter you can use to remove them...  use filter:  sph_CurrentlyOnline

and then do a php str_replace on the admin names...

Avatar
B. E. Johnson
Member
Free Members
sp_UserOfflineSmall Offline
Sep 17, 2013 - 1:34 am

Thanks. I'll try that. But, where do your filters go? I'm familiar with WP functions.php but SP has a lot of places in which to look.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 17, 2013 - 2:03 am

to look?  not sure what you mean...

put the hook in either your wp functions.php of the wp theme or your spFunctions.php file of the sp theme.... probably the latter since its only applicable to forum pages...

Avatar
B. E. Johnson
Member
Free Members
sp_UserOfflineSmall Offline
Sep 17, 2013 - 8:58 pm

not directly...  but there is a filter you can use to remove them...  use filter:  sph_CurrentlyOnline and then do a php str_replace on the admin names...

Ok. I'm looking in the Codex and do not find this filter. I do find spOnlineStats in the Codex, and it is in the theme spFoot.php. None of the filters in the Codex have any information regarding "arguments and description", so at a bit of a loss as to the direction to go in.

spOnlineStats apparently has a set number of arguments, because removing __sp('Currently Online: ') shifted the usernames down one to "Currently Browsing this Page:" and "Guests:". Replacing that section with ' ' removed the label but still displayed the username. So, I'm figuring that I need to do a str_replace on spOnlineStats and apply the filter to the sph_OnlineStats hook:

function remove_admins( $sp_OnlineStats ) {
 $DS_admins = array('admin1','admin2','admin3');
 $sp_OnlineStats = str_ireplace( $DS_admins, '', $sp_OnlineStats );
 return $sp_OnlineStats;
}
add_filter('sph_OnlineStats','remove_admins');

Which works! However, it leaves the comma delimiter if there are two admins logged in. So, I added that character into the variable array to be replaced. That, then, causes the comma to no longer show between non-admin usernames. I tried a few conditionals surrounding the above code to keep that from happening but no joy. No big deal.

 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 18, 2013 - 1:28 am

almost think you would want to put it into a loop... maybe explode the list on , to loop through... 

and process that way...  if str_replace had a callback version that would work too but dont believe there is...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626