Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Including moderators in "Top Posters" stats
Avatar
gorky5
Member
Free Members
sp_UserOfflineSmall Offline
Jun 30, 2014 - 7:22 am

Hi. If I make someone a moderator, and they were in the Top Posters forum stats, their name disappears from the list.

I know the Moderators have their own list which includes their post counts, but I'd like the option to have them also in the Top Posters list, especially if they're in both the Moderators and and Members user groups.

Is there a way to include forum moderators in the "Top posters" section of the stats panel? If not, can I suggest it becomes an option in General Display Settings?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jun 30, 2014 - 11:41 am

you can filter the query to include moderators and admins if you like...

use filter:  sph_stats_top_posters_query

which returns an object...  edit the object where element to remove the admin=0 and moderator=0 part of it...

holler if you need more help..

Avatar
gorky5
Member
Free Members
sp_UserOfflineSmall Offline
Jun 30, 2014 - 11:50 am

holler if you need more help..

Yes please! Could I get some step-by-step instructions? I'm not overly familiar with php, and I don't know where I find that filter.

Also, will changes get overwritten with a SP update or can I put them in a child theme?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jun 30, 2014 - 11:55 am

to your spFunctions.php file, add this:

add_filter('sph_stats_top_posters_query', 'my_stats_query');
function my_stats_query($query) {
    $query->where = 'admin=0 AND posts > -1';
    return $query;
}

that will add in moderators now when the stats run... remember, they are cached, so may take an hour to show up...

Avatar
gorky5
Member
Free Members
sp_UserOfflineSmall Offline
Jul 1, 2014 - 6:46 am

Thanks v much. I ran the sph_stats_cron hook and the changes showed up just fine.

Avatar
gorky5
Member
Free Members
sp_UserOfflineSmall Offline
Jul 1, 2014 - 10:38 am

Hi again. I added that code to the spFunctions.php file in my child theme. If I manually run the sph_stats_cron hook in Cron Inspector the moderators appear in the Top Posters list.

However, when the cron job runs again at its usual time (every 3600 seconds) it goes back to displaying only standard members, not members and moderators.

Is there something else I need to do to get this working consistently? What is resetting the list?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 1, 2014 - 2:13 pm

wouldnt have thought so, but maybe the sp theme isnt loaded by wp cron (which actually makes sense)...

so try moving it to your wp theme functions.php file...

Avatar
gorky5
Member
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2014 - 7:14 am

Thank you! Having it in the theme functions file worked.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 2, 2014 - 7:20 am

That's good news. Thanks for the update.
It's an interesting condition you met there. The Cron tasks can be actioned by loading a page from the back or the front end and depending on what is being run will determine whether any SP theme code is loaded or not. We will remember this wrinkle for the future...

andy-signature.png
YELLOW
SWORDFISH
Avatar
gorky5
Member
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2014 - 10:47 am

Further update: It did work for a few hours, but then something (presumably a cron task) changed and the list went back to just showing normal members.

The code is still in my theme functions file but now it doesn't seem to do anything at all. Very strange.

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