(I am very, very new to Drupal and have been basically learning as I go. Please be patient with me!)

I am attempting to make it so that various content categories can only be seen by paying members. I've done this by using the "Content Access" module (https://www.drupal.org/project/content_access) and assigning roles/content categories depending on pay levels. (I also downloaded the "Rules" module for use with this but haven't messed with it yet)

However, is there a way to make it so that a user is automatically assigned to a role after receiving payment? I can switch the role manually, but that would be really time consuming.

I haven't decided how we will be doing the payment yet, because I want to make sure whatever shopping cart/payment program we use can be integrated with this auto-role-assigning part.

(The website is to be an online magazine where you have to subscribe to read articles. If that makes anything clearer.)

Thank you so much for any help!

UPDATE: Have found an online guide on how to do this: http://www.10kwebdesign.com/10kblog/step-step-setting-membership-communi...

Comments

yoftahe.addweb’s picture

Hello Candystar,

Reviewed your post and here's the solution you can implement.

Please add rule as provided below:

{ "rules_upgrade_user_role" : {
    "LABEL" : "Upgrade User Role",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "RULE_WEIGHT",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : { "commerce_order_update" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "commerce-order:status" ], "value" : "completed" } }
    ],
    "DO" : [
      { "user_add_role": {
          "account"" : [ "commerce-order:owner" ],
          "roles"" : { "value" : { "ROLE_ID" : "ROLE_ID" } }
        }
      }
    ]
  }
}

Further, take care of below things:

1. Replace "ROLE_ID" with the role id, which you want to update after completing order.

2. Replace "RULE_WEIGHT" with weight, which should be greater than the weight of this rule "Create a new account for an anonymous order".

Hope this helps you.

Feel free to contact me incase of any further query/concern regarding this.

Thanks

jtjones23’s picture

I'm having the same issue. Touchnet is the payment gateway and I'm using Drupal 7. Any Suggestions would be helpful,

I'd like the role to be upgraded upon payment.

sprite’s picture

Read the following post and watch the following video:

https://commerceguys.com/blog/selling-content-drupal-commerce-using-cont...

https://commerceguys.com/blog/selling-node-access-drupal-commerce

The following module may help too, along with the rules module scenario in the video above:

https://www.drupal.org/project/commerce_license_billing

spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...