How do I get (in PHP) the gid of a node that is a group?

The group_audience field is present but empty, and I can't seem to populate it; presumably it is because that node is the only group, and it cannot itself be a member of the group it defines. (Why not is another issue that won't matter if I can just get the gid.)

1 Answer 1


Note that the entity id is the gid in the current OG 2.x version(s) (there is some confusion around the change from earlier OG versions where GIDs were NOT entity ids)


... the group ID is the identifier of the entity. if i have a group which is a node the group ID will the be node ID. If i create a group which is a user the group ID will be the user ID and if i have a group which is a taxonomy term the group ID will the term ID.

Use og_is_group to determine if the node in question is acting as a group.

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.