Support Forum

Adjusting Member Count At Bottom Of Forum Page

RC Ryan Collins
Ryan Collins
Member

Hi guys,

Curious whether it is possible to have the Member Stats not include free subscribers?

Right now my member count of 695 includes free subscribers.

So out of the total of 695 only around 550 are paying members.

It would be great to have the member count display 550 instead of 695.

Thanks for any insight,

Ryan

13 Answers

New Answer

MP Mr Papa
Mr Papa
Member

you will have to adjust the stats query…  so use the filter for the query…  sph_stats_members_count_query

something like:

add_filter(‘sph_stats_members_count_query’, ‘my_stats_query’);
function my_stats_query($spdb) {
# adjust our query here in $spdb
#    $spdb->where =
    return $spdb;
}

you just need to replace our query with yours…  in the comments, I suggested adding a mysql where clause to exclude free subscribers… cannot be more specific because I do not know how those users are identified…

RC Ryan Collins
Ryan Collins
Member

Thanks for the reply. I do have a few clarification questions…

Where do I place this new filter?

What would my query be?

Where and how could I add a mysql where clause to exclude free subscribers?

Thanks for any insight – much appreciated!

MP Mr Papa
Mr Papa
Member

As I said, I would need more info from you… I have not idea what free subscribers means on your site… its not a standard wp term or condition… so I dont know how to identify those users on your site…  with it, I could clarify the where clause…

the filter can go in your spFunctions.php template file…

RC Ryan Collins
Ryan Collins
Member

I understand.  Here’s a screen shot of my WordPress user interface (maybe this will help?)

You’ll see the “Subscriber” – there are 136 of them. These are the people I’d like to exclude from the member count.

users.jpg

Does this help you identify the users I would like to exclude?

Let me know when you can – much appreciated!

YS Yellow Swordfish
Yellow Swordfish
Member

How do these particular users relate in Simple:Press User Group terms? Trying to get the WordPress role to join in the SQL query is not that comfortable a task because of the terrible data storage WordPress employs for this information… It also needs php code to establish the data – it can not be accomplished with a sytraight query.

So you really need something else to be able to identify them with – like User Groups. If not that – are you using a membership plugin of some sort? Might that have the necessary data that could be used?

RC Ryan Collins
Ryan Collins
Member

I’m currently using the s2member membership site plugin.

I like the idea of using User Groups.

What I just did using “Map Users To User Group” is assign the default user group for subscribers to Guests

Then I checked the bubble next to “Users Are Limited to Single User Group Membership” (see below)

usergroups.jpg

 

I thought this may extract the subscribers from the member count in the forum, however as of right now the member count has remained unaffected and still includes the subscribers…

I feel I am on the right track and appreciate any insight you may have for me. Thanks!

MP Mr Papa
Mr Papa
Member

well, that would be a bit odd…  assigning actual users to the guest usergroup would really just affect permissions… they would still be members…  probably better to create a different usergroup and give them the permissions you want so the other member/guest checks would work as expected…

still, assuming everyone you wanted to count was in a usergroup, you could probably use this to adjust the counts:

add_filter('sph_stats_members_count_query', 'my_stats_query');
 function my_stats_query($spdb) {
     $spdb->join = array(SFMEMBERSHIPS.' ON '.SFMEMBERSHIPS.'.user_id = '.SFMEMBERS.'.user_id');
     $spdb->fields = 'COUNT(DISTINCT '.SFMEMBERS.'.user_id) AS count';
     $spdb->where = SFMEMBERSHIPS.'.usergroup_id != 1';
     return $spdb;
 }

the usergoup_id != 1 would just need to be updated with the sp usergroup you wanted to exclude…

think it will work, but have not tested and could give odd results depending on how users and memberships were handled… but give it a try…

RC Ryan Collins
Ryan Collins
Member

Alrighty, cool I will give that code a try.

Would you recommend I place that code at the bottom of the spFunctions.php template file?

Thanks!

YS Yellow Swordfish
Yellow Swordfish
Member

Top or bottom – doesn’t really matter as long as:

  1. It is between the opening php tag at the top of the file and the closing php tag at the bottom.
  2. After or before any existing functions in the file.
  3. You do not create any extra whitespace (empty lines) after the closing php tag at the bottom of the file.
RC Ryan Collins
Ryan Collins
Member

Got it.

I will try using Filezilla to accomplish this task.

In which folder can I find the spfunctions.php file?

Thanks!

YS Yellow Swordfish
Yellow Swordfish
Member

It is a part of your Simple:Press theme and will be in the /templates sub-folder of the theme folder.

Dopes FileZilla have editing capabilities? Never used it. Why not just use the Simple:Press theme editor built into the SP themes admin section?