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
Adjusting Member Count At Bottom Of Forum Page
Avatar
Ryan Collins
Member
Free Members
sp_UserOfflineSmall Offline
Aug 23, 2014 - 11:41 am

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

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 23, 2014 - 12:22 pm

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...

Avatar
Ryan Collins
Member
Free Members
sp_UserOfflineSmall Offline
Aug 24, 2014 - 9:56 pm

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!

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 25, 2014 - 12:02 am

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...

Avatar
Ryan Collins
Member
Free Members
sp_UserOfflineSmall Offline
Aug 27, 2014 - 10:22 am

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.jpgImage Enlarger

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

Let me know when you can - much appreciated!

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Aug 27, 2014 - 11:38 am

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?

andy-signature.png
YELLOW
SWORDFISH
Avatar
Ryan Collins
Member
Free Members
sp_UserOfflineSmall Offline
Sep 6, 2014 - 3:13 pm

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.jpgImage Enlarger

 

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!

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 6, 2014 - 6:44 pm

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...

Avatar
Ryan Collins
Member
Free Members
sp_UserOfflineSmall Offline
Sep 10, 2014 - 8:47 am

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!

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Sep 10, 2014 - 8:53 am

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.
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: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625