# Organic groups automatic audience selection

I am working with organic groups. Within each group, permitted users are allowed to create their own pages.

What my problem is that I need to set the audience for a new page automatically as the group the user is currently in. This is so that the user cannot manually change the group the post should go into but instead it's automatically and permanently set ( unless an administrator changes it ).

Does anyone know of a way that I might accomplish that?

You can use the prepopulate module to pass the group's gid to the node add form.
For example, the link will looks something like this:

node/add/discussion?edit[group_audience][und]=4


You could then hide the group selection box with css so the user cannot change it. For a more robust solution you would code a form hook. Here is an example.

I like the idea of using a Rule and have gotten it to work using the following Rule config: Event=Before Saving Content, Condition=Content is of a Certain Type, Action: Entity=Node, Group=Site:Current-group - YES - works like a charm!

I know this is an old thread, but I found this in my own search.

I'm new to this, but I think this is going to work for me.

NEW "RULE"

Event = Before Saving New Content --- Node/Content type Action = Data/set data value/node:og-group-ref:0 (Groups Audience)

With Drupal 7, you don't need the Prepopulate module.

You can just use this node/add/blog?og_group_ref=1 where 1 is the group ID.