HTML Logo by World Wide Web Consortium ( Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS. ocPortal 9 is superseded by Composr 10.

Head over to for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.

Working out if a User is in a secondary group

Login / Search

 [ Join | More ]
 Add topic 
#103276 (In Topic #20224)

Community saint


I tweaked the side stats.php code a while ago to display the number of members in a particular group, in our case the paid members group.

I would like to only show the actual number now if the logged on user is a member of an admin group - the reason being is that we are going to run a competition as we get close to a 1000 user milestone and do not want users to see the total.

So I know what the group ID is of the group that I want the number to display for is.
What I really need is a function that checks to see if the currently logged on member is a member of that group (in our case it will always be a secondary group.)

I have searched OCP code for such a function but cannot locate one.
Cannot I just not see it or has someone written such a function that I can use ?


Back to the top

Check if a member is in a group:



Check if a member is specifically in an admin group:



So we don't have a function to specifically check a specific group, but reading a list of groups lets you do that. But we do have a function for admins specifically already, as that is something we use in our code as it has an implicit meaning to ocPortal.

Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Support me on Patreon
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: