Greetings, could you please describe what rule(s) to modify to achieve this?

I have one kind of membership, and want it mapped to one role. Thanks!

Comments

zkrebs’s picture

I edited " "Apply subscription if line item is subscription product" rule,
Added Action:

Add user role
Parameter: User: [site:current-user], Roles: Member"

Seemed to work.

likewhoa’s picture

Status: Active » Closed (works as designed)

the actual correct way to do this is by doing the following.

1. First lets create a customer role
> drush rcrt 'customer' 'Customer'
2. Add a rule on subscription start
admin/config/workflow/rules/reaction/manage/rules_commerce_sp_subscription_started_insert
3. Add an action
admin/config/workflow/rules/reaction/manage/rules_commerce_sp_subscription_started_insert/add/1/action
4. Select "User -> Add user role"
5. Select "customer" role created in step 1 then click Save
6. Repeat steps 3 through 5 for
admin/config/workflow/rules/reaction/manage/rules_commerce_sp_subscription_started_update
 
Remove user role at end of subscription
 
1. Add an action
admin/config/workflow/rules/reaction/manage/rules_commerce_sp_subscription_validity_is_unset
2. Select "User -> Remove user role"
3. Select "customer" role and save
 
Now proceed to make another order and then view the users profile to see the newly added "customer" role
pinkonomy’s picture

@likewhoa
Hi,
is this possible to write this also when subscirption ends?
I am interested in giving the user a different role when his subscription ends.
Thanks!

likewhoa’s picture

@pinkonomy sure, just add a second action on the subscription end rule to add the new role after removing the old.

mstrelan’s picture

I would suggest it's slightly more efficient to add the roles to the ruleset "Subscription start" at admin/config/workflow/rules/components/manage/rules_commerce_sp_subscription_start as then you don't have to repeat yourself in step 6.