Using Organic Groups 7.x-2.9, I have two content types: - Series (Group) - Event (Group Content)
When creating an Event, a users has a select list of the Series they can assign this Event to (og_group_ref
). However, upon saving this new Event there is no og_membership
entity created (recorded in the table og_membership
) and, therefore, the new Event is not in the Series group.
If you then edit this event and select the Series, the og_membership
entity is created and the relationship is reflected on the Event. (Possibly related, there is no data in the table field_data_og_group_ref
).
Using breakpoints - everything appears to be the same with one exception: When OgMembership::save()
is called during the creation of a new entity the event entity object does have the nid; however, the node (Event) has not yet been saved in the node
table.
What needs to be done in order to have the relationship when a new node (that is a group content) is created?
[EDIT] It seems the og_membership
entity is being saved and then deleted. I found this issue regarding data loss. I don't think it's related (as of yet) because I don't have any active OG rules; however, it did make me check further. When creating group content and associating it with a group, the og_membership
table auto increment does increase by 1, although no record was written. This tells me a record was written and deleted.
[EDIT] The above linked issue led me to another hook_node_insert
that is used in this site. This hook uses entity_metadata_wrapper
to set a field value, commenting this out stops the og_membership entity from being deleted.