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
Display Admin under Top Posters?
Avatar
Stang5_0
Member
sp_UserOfflineSmall Offline
Nov 21, 2016 - 1:25 pm

Forgive if this has been answered elsewhere already as I was not able to find mention.

Can the admin be displayed under Top Posters?  I don't see where that option would be like I do for members and moderators.

Thank You.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 21, 2016 - 1:54 pm

There is no option to do allow for it bu a simopel filter can do the trick.

See this post: https://simple-press.com/suppo.....t/#p163700

This guy wanted to show moderators in the top posters. All you need to do to show admins is remove the bit in the code where it says 'AND admins=0'. Like this:

add_filter('sph_top_poster_stats_query', 'add_mods'); 
function add_mods($query) {
     $query->where = 'hide_stats = 0 AND posts > -1';     
     return $query; 
}

All you need to do is part 2 of that post. Part 1 is already in the plugin core

andy-signature.png
YELLOW
SWORDFISH
Avatar
Stang5_0
Member
sp_UserOfflineSmall Offline
Nov 21, 2016 - 2:40 pm

Thanks for the response.

Here is what sp-user-functions.php looks like

<?php
add_filter('sph_top_poster_stats_query', 'add_mods');
function add_mods($query) {
$query->where = 'hide_stats = 0 AND posts > -1';
return $query;
}
?>

And starting at line 272 of sp-db-statistics.php

function sp_get_top_poster_stats($count) {
$spdb = new spdbComplex;

$spdb->found_rows = true;
$spdb->table = SFMEMBERS;
$spdb->fields = SFMEMBERS.'.user_id, display_name, posts';
$spdb->join = array(
SFMEMBERSHIPS.' ON '.SFMEMBERS.'.user_id = '.SFMEMBERSHIPS.'.user_id',
SFUSERGROUPS.' ON '.SFMEMBERSHIPS.'.usergroup_id = '.SFUSERGROUPS.'.usergroup_id');
$spdb->where = 'hide_stats = 0 AND posts > -1';
$spdb->groupby = SFMEMBERS.'.user_id';
$spdb->orderby = 'hide_stats ASC, posts DESC';
$spdb->limits = "0, $count";

$topPosters = $spdb->select();
return $topPosters;

I've run the cron but it is still not showing up.

Thought I followed it pretty close but maybe not.

Stang

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 21, 2016 - 3:34 pm

I did say you should only do part 2 of that original post. Looks to me like you have taken the filter out of the statistics file. You will need to put that back as it was.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Stang5_0
Member
sp_UserOfflineSmall Offline
Nov 21, 2016 - 3:48 pm

Putting it back in I get the following at the top of the page:

erid, 'lastvisit', 0); } ?>

3
 
 

 

 

Warning: Cannot modify header information - headers already sent by (output started at /home/obmcsalt/public_html/wp-content/plugins/simple-press/forum/database/sp-db-statistics.php:412) in /home/obmcsalt/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 62

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/obmcsalt/public_html/wp-content/plugins/simple-press/forum/database/sp-db-statistics.php:412) in /home/obmcsalt/public_html/wp-content/plugins/wp-embed-facebook/lib/class-wp-embed-fb-plugin.php on line 221

This also causes my signature to show back up (we're talking about this in another post)

Capture-1.PNGImage Enlarger

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 21, 2016 - 3:55 pm

I was just checking as you posted. Seems I was wrong. The filter has not yet gone into the core code because that post and request was made since the last update and the filter is still waiting to be released so my apologies, but you DO need to do part one of that old post as well.

And those error message suggest you have made an error in the coding,

For the record here is the entire function as it should be:

function sp_get_top_poster_stats($count) {
    $spdb = new spdbComplex;

    $spdb->found_rows = true;
    $spdb->table = SFMEMBERS;
    $spdb->fields = SFMEMBERS.'.user_id, display_name, posts';
    $spdb->join = array(
SFMEMBERSHIPS.' ON '.SFMEMBERS.'.user_id = '.SFMEMBERSHIPS.'.user_id',
SFUSERGROUPS.' ON '.SFMEMBERSHIPS.'.usergroup_id = '.SFUSERGROUPS.'.usergroup_id');
    $spdb->where = 'hide_stats = 0 AND admin=0 AND moderator=0 AND posts > -1';
    $spdb->groupby = SFMEMBERS.'.user_id';
    $spdb->orderby = 'hide_stats ASC, posts DESC';
    $spdb->limits = "0, $count";

    $spdb = apply_filters('sph_top_poster_stats_query', $spdb);
    $topPosters = $spdb->select();
    return $topPosters;
}

andy-signature.png
YELLOW
SWORDFISH
Avatar
Stang5_0
Member
sp_UserOfflineSmall Offline
Nov 22, 2016 - 10:59 am

So starting fresh now with cache turned off and whatnot, to accomplish what I am trying to accomplish should I go to that other post and follow all steps?  Thanks, I'm just trying to clarify what  I need to do.

Regards,

Stang

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 22, 2016 - 12:13 pm

Correct - with the one exception of this line:

$query->where = 'hide_stats = 0 AND posts > -1';

which you will need to change from the one used in that other topic.

And apologies for the confusion.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Stang5_0
Member
sp_UserOfflineSmall Offline
Nov 22, 2016 - 1:08 pm

No problem at all confusion happens.  🙂

OK, so here is what my sp-user-functions.php looks like:

<?php
add_filter('sph_top_poster_stats_query', 'add_mods');
function add_mods($query) {
$query->where = 'hide_stats = 0 AND posts > -1';
return $query;
}
?>

And from sp-db-statistics.php I have this:

function sp_get_top_poster_stats($count) {
$spdb = new spdbComplex;
$spdb->found_rows = true;
$spdb->table = SFMEMBERS;
$spdb->fields = SFMEMBERS.'.user_id, display_name, posts';
$spdb->join = array(
SFMEMBERSHIPS.' ON '.SFMEMBERS.'.user_id = '.SFMEMBERSHIPS.'.user_id',
SFUSERGROUPS.' ON '.SFMEMBERSHIPS.'.usergroup_id = '.SFUSERGROUPS.'.usergroup_id');
$spdb->where = 'hide_stats = 0 AND moderator=0 AND posts > -1';
$spdb->groupby = SFMEMBERS.’.user_id’;
$spdb->orderby = 'hide_stats ASC, posts DESC';
$spdb->limits = "0, $count";
$spdb = apply_filters(‘sph_top_poster_stats_query’, $spdb);
$topPosters = $spdb->select();
return $topPosters;
}

I have nothing showing up under my Top Posters yet so I'm wondering did I miss something here that you can see?  I did run my chron but still no change.

Thank you!

Stang

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 22, 2016 - 5:34 pm

Looks good as far as I can see. So - nothing showing at all? Can you go to the toolbox > Error Log. Clear it using the button at the bottom. Then run the CRON job for the user stats and check back on the log to see if there is anything reported?

andy-signature.png
YELLOW
SWORDFISH
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