I'm experimenting with a sub-module for Organic Groups that adds some sample content to help people get started with the module.
I'm having a hard time with the code to create an entity reference.
I have first created some groups and some group nodes. I'm now trying to create some group content in a group_content content type, but I'm struggling with how to create the link between the group content node and the group that owns it.
Any help would be appreciated or links to helpful resources.
UPDATE:
Initially, I thought I was just trying to create an entity reference. But, I think it's more specific than that. I'm finding a number of references to this fuction - "og_group()" - to add a og membership. This might be key to my answer.
Comments
My difficulties were not so much around entity references or the specifics of creating content nodes for Organic Groups. I was dealing with another unresolved conflict between creating content types and content in the same module (using config files to generate the content types and fields).
See: https://github.com/backdrop-contrib/og/issues/102
Here is my code that is working, as long as it's in a separate sub-module from the config files creating the content types.
Specifically see part about "og_group_ref" for the entity reference. I had to get the NID for each group in order to make this connection.