I'm trying to allow people to subscribe to an organic group when buying a specific product. The thing is that I need to set the OG context in the order, not the product or anywhere else.
Use case: The anonymous user completes an order. The site admin reviews it and then he may or may not grant the anon user the access to a specific role from a list.
How I´m trying to accomplish that:
- I've installed Drupal Commerce, Rules and Organic Groups.
- I create an OG audience field inside commerce orders (*og_group_ref_commerce*).
- I set a rule with some conditions (if the order is set to "completed", and if the user is an anon...) and some actions (a loop to create the new user and assign him a role).
And I'm adding a special action (which doesn´t work):
Subscribe user to group
User Data selector: account-fetched:0 Group Data Selector:
I´ve tried another way, without any success:
User Data selector: account-created (in and outside the loop that created the user) Group Data Selector: site:og-context--node
Note: As the order doesn´t initially have the group audience context, I have to edit it in order to assign it a group. After saving it (it is still in "pending" status), I edit it again to change it to "completed".