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?
Support Forum
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…
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.
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…
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.
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…