I would like to retrieve the Group ID before the referencing node is created. It seems that the ID could be parsed from the URL or retrieved from the $form_state array like so:

function my_module_form_alter(&$form, &$form_state, $form_id) {
  $gid = $form_state['entityreference_prepopulate']['foo_entity_type']['bar_bundle_type']['og_group_ref'][0];
}

Is this the right method or is there a builtin function I should be leveraging instead?

Thanks

Comments

amitaibu’s picture

You can use og_context().

eft’s picture

Ah, ok. Another module to add to my platform. Thanks :)

eft’s picture

Status: Active » Closed (works as designed)

closing