Hi there,
Another simple one this in response to the thread here. Just thought I’d have a go at making something to do this 😉
Basically this plugin returns the group name, group ID and a count for the members in the group.
USAGE
MULTIPLE GROUPS
<h2>Multiple Groups</h2>
{exp:member_group_count:multiple_groups groups="1|2|3|4|5|6"}
Group ID = {group_id}
Group Count = {group_count}
Group Title = {group_title}
<hr >
{/exp:member_group_count:multiple_groups}
PARAMETERS groups=”1|2|3|4|5|6” Pipe delimited list of member group ids
VARIABLES Use of {switch="Aye|Bee|Sea|Dee"} variable permitted
ONE GROUP
<h2>One Particular Group</h2>
{exp:member_group_count:one_group group="1"}
Group ID = {group_id}
Group Count = {group_count}
Group Title = {group_title}
<hr >
{/exp:member_group_count:one_group}
PARAMETERS group=”1”
ALL GROUPS WITH MEMBERS
<h2>All Groups With Members</h2>
{exp:member_group_count}
{switch="Aye|Bee|Sea|Dee"}
Group ID = {group_id}
Group Count = {group_count}
Group Title = {group_title}
<hr >
{/exp:member_group_count}
VARIABLES Use of {switch="Aye|Bee|Sea|Dee"} variable permitted
Hope it’s of help to someone out there.
Best wishes,
Mark
Hiya,
Thanks for the post 😉 I am still trying to update this one so that if the group has no members then you will get 0 for the count other than at the moment you don’t get any output.
Actually in the single group it does do this and will show a zero count if there are indeed no members in that group but I need to update the multiple groups tags so that they spit out a zero count. The plugin will still work fine just won’t give any output at all for empty groups.
Hope it’s useful though.
As for the Aye, Bee, Sea, Dee that’s how you spell those letters isn’t it? 😉 😊 😉
Best wishes,
Mark
Yes, I had an idea not sure how useful yet. I just want to count the number of members currently in the group. So this number would increase each time a member signs up. Next I want to basically make an array that has the members count for each day of the week.
Like this:
var myvalues = [
{exp:member_group_count:one_group group="5"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5"}{group_count}{/exp:member_group_count:one_group},
];
of course that will output same number of members each time.
[9,9,9,9,9,9,9]
If I had a parameter that could limit the results to maybe day1,day2,day3 etc. (So day1 would be today, day2 would be yesterday, day3 would be day before yesterday and so on.
var myvalues = [
{exp:member_group_count:one_group group="5" offset_day="day1"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5" offset_day="day2"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5" offset_day="day3"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5" offset_day="day4"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5" offset_day="day5"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5" offset_day="day6"}{group_count}{/exp:member_group_count:one_group},
{exp:member_group_count:one_group group="5" offset_day="day7"}{group_count}{/exp:member_group_count:one_group},
];
[9,13,25,23,35,44,50]
each number would be the count for a day of the week. (Monday - Sunday) So I will feed this data into a charting script and get the last seven days at a glance.
…also I just thought about adapting this to entry activity which should be a bit easier with the parameters available in the weblog entries tag.
Thanks for “noodling” this with me. This is just an Idea I had and it’s not mission critical or anything. Thanks.
Hiya,
Hey Mark, Any way to adjust so a group can be excluded? something like:or{exp:member_group_count:multiple_groups groups="not 1"}
{exp:member_group_count:multiple_groups groups!="1"}
At the moment there isn’t but I am working on a new version which will have an exclude_groups=”1|2|3” parameter. Will hopefully have that ready as soon as possible so watch this space 😉
Best wishes,
Mark
Hiya,
I have a new version of the plugin now available. I’m going to add it to this entry in the post but once I’ve kicked it around quite a bit more then I will add it to the top post. If you can kick it around too to see if anything breaks then that would help me out massively as then having at least two people playing with it should show me if I’ve done anything wrong anywhere.
Hope it works okay for you.
Usage Instructions
Single GroupParameter group=”5” Provide a single group ID using this parameter and if there are results for this member group then they will be returned. All Groups (with exceptions){exp:mb_member_group_count:single_group group="5"} Group ID = {mb_group_id} Group Count = {mb_group_count} Group Name = {mb_group_title} {/exp:mb_member_group_count:single_group}
Parameter exclude_groups=”5|6|7” If this parameter is provided then all groups except those listed in the parameter will be returned. If left empty or not supplied then all groups with data in will be returned.{exp:mb_member_group_count:all_groups exclude_groups="5|6|7"} Group ID = {mb_group_id} Group Count = {mb_group_count} Group Name = {mb_group_title} <hr > {/exp:mb_member_group_count:all_groups}
Hopefully it all should work fine though.
Best wishes,
Mark
Well just noticed on silly thing just by looking at my usage examples above. Why would I want to use the multiple_groups version with an exclude_groups=”5” parameter when I just supplied 5 in the groups parameter? 😊
I will probably just update the plugin to have just the single_group and all_groups functions and then with the all_groups function include the exclude_groups=”5” parameter.
Pretty silly of me to exclude something I’d just included!! 😊
Will get this done first thing tomorrow now.
Best wishes,
Mark
Plugin usage and plugin now updated and can be found two entries above this one.
Will leave it there for a while until it’s been played with a lot and to see if anyone can break it. Please let me know if it does break. If not then I’ll move it on up to the top entry for all to find easily.
Best wishes,
Mark
looks really good and the exclude does what it says on the tin.
The only problem is losing the ability to give out multiple groups. I would use multiple groups with the |, like this:
{exp:mb_member_group_count:single_group group="9|10"}
Group ID = {mb_group_id}
Group Count = {mb_group_count}
Group Name = {mb_group_title}
{/exp:mb_member_group_count:single_group}
And this would count the two groups up (I have them ad group and group admin with differing permissions, this the reason for this setup)
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.