Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
You can set up OG to be completely transparent to users:
- when a user creates content, the group reference field is hidden, and its value is set automatically
- when the content is edited, the group reference field is still hidden
This can be accomplished with the Entityreference prepopulate module.
- Enable the Entityreference prepopulate module
- Edit the group membership field on your group content entity
- Under 'Additional behaviours' enable 'Entity reference prepopulate', then select:
- 'Action: Hide Field'
- 'Apply action on edit'
You then need to create links to create new content which contain the prepopulate data in the URL, in the form: node/add?og_group_ref=GROUP_NODE_ID
Comments
Additionally, you can use
Additionally, you can use Menu Tokens to create links with paths like node/add/group_content?og_group_ref=[node:nid]. When menu is placed on a group page, [node:nid] will produce the current group ID.