2

I'm trying to get the prepopulate module to work with og with little success. From what I understand I can do ?edit[group_audience]=123, and by going through the code it seems the prepopulate plugin does what it is supposed to, and sets the dropdown #value to 123, but for some reason this doesn't work at all.

I've also found some information saying that it is possible to prepopulate the field using ?gids[]=123, has anyone had success with this, or has a real proper solution?

Owen Blacker
  • 4,117
  • 2
  • 33
  • 70
Marco
  • 2,329
  • 1
  • 21
  • 25

5 Answers5

2

So... the right way to do this for D 7.22 and OG 7.x-2.1 is:

node/add/[content-type-machine-name]?og_group_ref=[group-id]&destination=node/[group-id]

The above answers did not work for my setup.

See how I wasted my Sunday on this here: Drupal Organic Groups Pre-populated Audience Field

0

Don't need the prepopulate module:

?gids_group[]=123

Found this in the Organic Groups readme:

You may craft your own URLs which produce useful behavior.

For example,

node/add/group-content?gids_node[]=4 

will add a select the group with node ID 4, in the node form.

The prefixed entity can change to indicate other entity types allowing crafting the URL and you can have multiple variables, for example,

node/add/group-content?gids_node[]=4&gids_user[]=3&gids_group[]=5,6,7

The above URL will select the group with node ID 4, and the group with user ID 3, and the groups with the unique group ID 5, 6 and 7. Note that the actual entity of group ID 5, 6 and 7 can be any entity (e.g. nodes or users).

Bryan Waters
  • 636
  • 4
  • 11
  • Welcome to stackoverflow. Just prettied up your answer. Put in some line breaks and 4 spaces marks your examples as code. – Bryan Waters Dec 11 '12 at 21:37
0

By appending ?gids[]= to your node/add URL, you can specify the group audience. By throwing in a comma-delimited list of nids, you can specify multiple audiences.

geek-merlin
  • 1,720
  • 17
  • 13
0

For Drupal 7, with og 7.x-2.1, you need to have the entity reference prepopulate module installed (and follow the instructions in its readme). Once you do that, then the rest works like magic. Without that module installed/enabled, nothing happens when you try to do what is below. This url achieves the desired result of pre-poulating og_group_ref field with the group with id 1135: http://[site]/node/add/group-post?og_group_ref=1135

hanksterr7
  • 105
  • 1
  • 4
0

Did you try ?edit[group_audience][]=123 ?

Group audience is a multiselect box so it is possible that you need to use this syntax that allow to set multiple values.
?edit[group_audience][]=123&edit[group_audience][]=42&edit[group_audience][]=1

DuaelFr
  • 395
  • 1
  • 5