I have used OG module to implement the Groups functionality. I want to get:

  1. Count of all groups that are there on the website
  2. Count of groups that a user has joined

How can I do this?

Note: My preference would be to use an existing function (if there is any).

1 Answer 1


To get Count of all groups....

$groups = og_get_all_group($group_type = 'node');
$count = count($groups);

To get User Groups Count

$user_groups = og_get_groups_by_user();
$user_count = count($user_groups);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.