Skip to:
Content
Pages
Categories
Search
Top
Bottom

Issue with “bbPress Advanced Statistics”

  • @ajtruckle

    Participant

    I have only just noticed this. I use the “bbPress Advanced Statistics” plugin as I like the way it presents the data at the bottom on the forum page.

    However, if I “log out”, it still lists all the names of the users from the last 24 hours. That is not right. It should only list last 24 forum activity if a user is logged in. Technically it is exposing users names for a non logged in user when I don’t want it to.

    I am using latest bbPress 2.6.2

    Any advice appreciated. Thanks.

Viewing 13 replies - 1 through 13 (of 13 total)
  • @robin-w

    Moderator

    @ajtruckle

    Participant

    @ajtruckle

    Participant

    Only problem with the other forum is it doesn’t look like it is supported any more.

    @robin-w

    Moderator

    may well be, but you can’t expect us to support every plugin 🙂

    @ajtruckle

    Participant

    True. 🙂

    @casiepa

    Moderator

    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/

    @ajtruckle

    Participant

    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.

    @robin-w

    Moderator

    @ajtruckle time for you to start learning php ??:-) https://www.udemy.com/course/php-mysql-tutorial/

    @ajtruckle

    Participant

    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 …!

    @robin-w

    Moderator

    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.

    @ajtruckle

    Participant

    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 …

    @robin-w

    Moderator

    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;
    }

    @ajtruckle

    Participant

    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.

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.
Skip to toolbar