Mcardle Posted June 14, 2017 Share 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 Link to comment Share on other sites More sharing options...
Daniel F Posted June 15, 2017 Share 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(); Link to comment Share on other sites More sharing options...
Mcardle Posted June 15, 2017 Author Share 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 Link to comment Share on other sites More sharing options...
Daniel F Posted June 15, 2017 Share 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; Link to comment Share on other sites More sharing options...
Mcardle Posted June 15, 2017 Author Share 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 Link to comment Share on other sites More sharing options...
Daniel F Posted June 15, 2017 Share 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: Link to comment Share on other sites More sharing options...
Mcardle Posted June 16, 2017 Author Share 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 Link to comment Share on other sites More sharing options...
Zephers Posted July 8, 2017 Share 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? Link to comment Share on other sites More sharing options...
newbie LAC Posted July 9, 2017 Share 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> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.