Videos

Selling Content with Drupal Commerce (with roles and Content Access)

Date Published: 
12/16/2011
Duration: 
22:17

In this screencast we'll use Drupal's built-in access control mechanisms (using the Content Access module) to grant access to premium content to users who have a "premium" role.

Here's the recipe:

* Enable Content Access and the ACL (optional) module.
* Create a role called "premium"
* Create a content type called "Premium Content" and put some great content in it.
* Verify that users can only access the premium content if they have the premium role.
* Create a product representing the premium role.
* Create a rule that grants the premium role on order completion:
* After updating an order
* If the order state is Completed
* And the order contains our premium product
* Add a role to the user who is the owner of the order

That's really all there is to it.

Note: You may want to enable recurring payments for a "membership." There are a few payment gateways available in the Commerce Guys Marketplace and there is also a great module developed by Ryan Szrama for Recurly integration.

What is Content Access?

This module allows you to manage permissions for content types by role and author. It allows you to specifiy custom view, edit and delete permissions for each content type. Optionally you can enable per content access settings, so you can customize the access for each content node.

Features
It comes with sensible defaults, so you need not configure anything and everything stays working
It is as flexible as you want. It can work with per content type settings, per content node settings as well as with flexible Access Control Lists.
It tries to reuse existing functionality instead of reimplementing it. So one can install the ACL module and set per user access control settings per content node.
Furthermore the module provides conditions and actions for workflow-ng / rules, which allows one to configure even rule-based access permissions.
It optimizes the written content node grants, so that only the really necessary grants are written. This is important for the performance of your site.
It takes access control as important as it is. E.g. the module has a bunch of simpletests to ensure everything is working right.
So the module is simple to use, but can be configured to provide really fine-grained permissions!

How To?
Itangalo (Johan Falk) has recorded a great Learn Content Access series.
The online handbook documentation.