I try to use [node:og_group_ref], but that gives me the group node title and I need the GID, I am sure there should be a way to get it but I haven't found it


In Organic Groups 7.2 the Node idea and Group id are the same. So if you are using views you can do the following:

Add field "Content: Nid" and exclude if from display. Any field arranged below the above can use [nid] as a rewrite giving you the Group ID.

Does this help?

| improve this answer | |
  • Since the question seems to imply the group ID is stored in og_group_ref, I believe the author is looking for ID of the group(s) of which the current node is a member. Taking the node ID does not solve it, then. – tanius Mar 15 '16 at 19:24

You can make the [node:og_group_ref] token output the numerical ID instead of the group name by setting up the "Token" display mode for your content type and choosing the "Entity id" formatter for that field:

As shown in this comment in the issue queue:

  1. Go to "Structure → Content Types → [your content type] → Manage Display".
  2. Click "Custom Display Settings" below the field list, enable the "Token" option and save.
  3. Go to the new "Token" display mode in the horizontal tabs on the top.
  4. For yourog_group_ref field, set "Format: Entity id" and save.
| improve this answer | |

Like so: [node:og-group-ref--og-membership--1:0:id]

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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