Only problem with the other forum is it doesn’t look like it is supported any more.
may well be, but you can’t expect us to support every plugin 🙂
I can confirm that 1.5 was the last version of that product from what it seems and that no further development is done (technical talk: even the /trunk folder is missing so no updates could happen anymore). The plugin is now marked correctly: https://wordpress.org/plugins/bbpress-improved-statistics-users-online/
OK. Thanks. Because we need a good plugin like this (if not core functionality anyway). But it should expose usernames if we don’t want it to when no one is logged in.
I will leave it active as it is better than nothing and I don’t have an alternative that I know of that is without charge.
I have done php. Actually wrote a website a few years ago that worked with a my-sql database. I also did a backend which was a Microsoft Visual C++ standalone executable that had access to the database for managing content. The site is not live any more.
My struggles are with debugging. It is not like Visual C++ when I can run through it step by step.
And there is the basic mechanics of how the whole thing works. No manuals with details information about bbPress mechanics.
So I already have a good knowledge but I am leading myself blind with it and I don’t like that …!
I only started php in 2014 – necessity makes a great motivator.
I doubt if it would take you that long to find where the output is, and add a is_logged_in test to it.
It seems to be this html that builds a load of divs:
function build_html() {
$this->sort_users();
$data = $this->stats_builder();
$HTMLOutput = "";
foreach( $data as $key => $html ) {
$HTMLOutput .= "<div class='bbpas-" . $key . "' id='bbpas-" . $key . "'>" . $html . "</div>";
}
return $HTMLOutput;
}
That is called by this:
function widget( $arg, $instance ) {
echo $arg['before_widget'] .
$arg['before_title'] .
$instance['heading'] .
$arg['after_title'] .
$this->_parent->online->build_html() .
$arg['after_widget'];
}
So the is_logged_in
test would have to be applied to build_html
and if $key
is a certain value do the logged in test.
Elsewhere i found this:
// Section: Users active in last x hours
if(in_array( 'last_x_hours', $stat ) ) {
$HTMLOutput["inactive"] = $this->section_userstats( $this->stats, "inactive" );
}
So I guess the $key
of interest is inactive
. Funny index to use for that …
ok, very quick as I am passing
If you just want it to display for logged in but not for others, then just change
return $HTMLOutput;
to
if (is_user_logged_in()) {
return $HTMLOutput;
}
Since the function still needed a return value I wrapped the actual for
loop instead.
But I don’t know if it was coincidence or what but i site seemed more sluggish. I have commented that code out even though it worked. Maybe the check is done fairly frequently. I don’t know.
I will leave it for the moment as it is. Worse case scenario is that I switch off showing the last 24 hours activity as there is a setting for that.