Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: sarahwhite42 on July 23, 2014, 12:27:00 PM

Title: Is there a way...
Post by: sarahwhite42 on July 23, 2014, 12:27:00 PM
Our site has a membergroup called "Inactive" for people that have left the site but might return.  Does anyone know if there is a (hopefully easy) way to keep the people in this group from showing up in our total member count?  We're on SMF 2.0.4 I believe
Title: Re: Is there a way...
Post by: margarett on July 23, 2014, 01:27:29 PM
First of all, if you're really on 2.0.4, then you should update your forum ASAP. You are 2 security versions behind (and another 2 of other improvements)

As for your main question, do you want them to be decreased from the total members count only or do you also want to hide them, eg, from Memberlist?
Is this "Inactive" the primary membergroup of said members?
Title: Re: Is there a way...
Post by: sarahwhite42 on July 23, 2014, 08:14:22 PM
We would like them removed (total count decreased) and hidden from member list if possible.  And yes it's the primary membergroup of said members.

Also, we have now upgraded to 2.0.8
Title: Re: Is there a way...
Post by: Kindred on July 23, 2014, 08:20:12 PM
There is actually no good way to do that.
Title: Re: Is there a way...
Post by: sarahwhite42 on July 24, 2014, 08:27:33 AM
our main goal is to have them removed from the total count.  There's no way to do that without deleting the accounts?
Title: Re: Is there a way...
Post by: Arantor on July 24, 2014, 08:29:47 AM
Well, there's banning them and there's forcibly deactivating their accounts, both of which would remove them from the list, but neither are especially desirable. SMF is sadly not designed to accommodate such a situation.
Title: Re: Is there a way...
Post by: margarett on July 25, 2014, 09:45:02 AM
I see that you already marked this as solved but anyway, here goes nothing.

For the memberlist I would need to take a deeper look at it. But for the members total that shows up in BoardIndex/InfoCenter, you can actually do something like this:

Subs.php, find:
// This looks weird, but it's because BoardIndex.php references the variable.
Add before:
//How many members are "inactive"?
$request = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}members AS total
WHERE id_group = {int:group}',
array(
'group' => 9,
)
);
list ($total) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

(you need to adapt that "9" to your actual group ID)

Find (few lines below):
'total_members' => comma_format($modSettings['totalMembers']),
Replace with:
'total_members' => comma_format($modSettings['totalMembers'] - $total),

Please note that this is not actually very efficient as it will add a query to pretty much every page load. It should be cached or , better yet, handled at the membergroup edit stage by storing the current number of members of said group in a "settings" record so that the value is always available without any additional query. But that's what I can get out in a 5-minutes test :P
Depending on how busy your forum is, this can affect it negatively for little gain. If it isn't very busy than you probably won't even note it's there.
Title: Re: Is there a way...
Post by: Arantor on July 25, 2014, 09:46:23 AM
Hmm, that presumes group 9 won't be a secondary group at all (which makes it even more expensive) and won't do anything for the member list which is what seems to be even more imposing.
Title: Re: Is there a way...
Post by: margarett on July 25, 2014, 09:48:56 AM
Yup. (S)he said that it was primary membergroup. The memberlist would take me the time that I can't really spend now :(