Mcardle Posted June 14, 2017 Posted June 14, 2017 Hello, I would like to display on the front end the amount of members in a group that will update automatically. Basically we run a game server where access is purchased through our store and once we have X amount of members with access we upgrade it, we would like to show members how many people have access via the group so they can see how close we are to the next upgrade if that makes sense. So like what you see in the ACP > Members > Groups but being able to put it in PHP or a block on the front end. Thanks
Daniel F Posted June 15, 2017 Posted June 15, 2017 You can use the getCount method inside the Group class for this. $group = \IPS\Member\Group::load(10); $count = $group->getCount();
Mcardle Posted June 15, 2017 Author Posted June 15, 2017 Thanks for the reply @Daniel F would I copy that in to a block? I'm not as experienced as my profile may imply
Daniel F Posted June 15, 2017 Posted June 15, 2017 24 minutes ago, MadMcardle said: Thanks for the reply @Daniel F would I copy that in to a block? I'm not as experienced as my profile may imply Exactly. $group = \IPS\Member\Group::load(4); $count = $group->getCount(); echo "Total members in group 4:" . $count;
Mcardle Posted June 15, 2017 Author Posted June 15, 2017 Sorry @Daniel F, how do I find out the number of the group? And I would simply change the 4 to that number? At the moment it is just showing the code front end
Daniel F Posted June 15, 2017 Posted June 15, 2017 2 hours ago, MadMcardle said: Sorry Daniel, how do I find out the number of the group? And I would simply change the 4 to that number? At the moment it is just showing the code front end Yes, change the 4 to the group id ( which can be found in the URL while editing the group) You'll need to create a php block as described here:
Mcardle Posted June 16, 2017 Author Posted June 16, 2017 Geez this was so simple actually, I was just over thinking it and making it complicated lol, need to learn php a lot more, thanks for the help
Zephers Posted July 8, 2017 Posted July 8, 2017 Thanks for this - if I wanted multiple groups in the same block with their counts (like a list) how would you code that?
newbie LAC Posted July 9, 2017 Posted July 9, 2017 6 hours ago, Zephers said: Thanks for this - if I wanted multiple groups in the same block with their counts (like a list) how would you code that? Create html block <ul> {{foreach \IPS\Member\Group::groups(true, false) as $group}} <li> {$group->formattedName|raw}: {$group->getCount()} </li> {{endforeach}} </ul>
Recommended Posts
Archived
This topic is now archived and is closed to further replies.