Excellent. A simple rule if you do not know it. All edits must be made in plain text – using tools like Notepad (Win) or TextEdit (macOS). To edit existing files on your server, your hosting control panel will usually come with a simple editor.
1: Editing existing code file:
The file is /wp-content/plugins/simple-press/forum/database/sp-db-statistics.php
About two thirds down – on line 272 you will find the function sp_get_top_poster_stats()
Immediately before the line of code…
$topPosters = $spdb->select();
add the following – so the last 3 lines looks like:
$spdb = apply_filters('sph_top_poster_stats_query', $spdb);
$topPosters = $spdb->select();
return $topPosters;
Use the ‘raw code’ button on the code and copy from the popup.
2: Add new code file:
Create a new code file with the code below. The file needs to be named sp-user-functions.php and needs to reside in the ‘wp-content’ folder. NOT in a plugin folder. Simple:Press will find it in wp-content and will never overwrite it or change it.
This is the code function:
add_filter('sph_top_poster_stats_query', 'add_mods');
function add_mods($query) {
$query->where = 'hide_stats = 0 AND admin=0 AND posts > -1';
return $query;
}
Now… this code has to be surrounded by php opening and closing tags which I can’t easily show in the code box. So – first line of the file show the opening tag <?php and at the end of the file the closing tag ?> – but remember that there must be no empty lines at the top or bottom. The tags must be on first and last lines. It really is easy!
Finally – remember that the stats are cached and only refresh themselves about once an hour so you will not necessarily see an instant change. If you want to update them then you can do so in the forum admin > toolbox > cron panel and run the sph_stats_cron task in the run box provided.
And we will add that filter to the code in the next update.