Organic Groups and Rules: Automatically set group audience field

On the on hand you can achive this using OG Context. But it's more fun not taking care of this links and the Prepopulate module.

So how to do this at all? All you need is Organic Groups and Rules. Optionally you can hide the group audience field from users via Field Permissions module. By the way ... my users can only be member in one group. don't know at the moment if this matters.

Here's my rules setup:


After saving new content - Of course this should be the group content type ;)


Data value is empty
data selector: site:current-user:og-membership.

Here I checked Negate. So this rule is only triggered if a users is member of a group


Add entity to group

Entity data selector: node

Group data selector: node:author:og-user-node or site:current-user:og-user-node
I think the first one is the more safe value. Especially if you autocreate content and set an author via Feeds.


Now every time a group member is creating group content it's asigned to the group(s?) of the author.


That's all ;)