Back to top

How to create a time based subscription using uc_roles.

This blog is about how to create a time based subscription using uc_roles.


Requirements: Drupal 6.x, Ubercart module, uc_roles module.

We can create a time based subscription for a user for a given role. The user will be subscribed to that role for a given period of time, after which the role will expire. The subscription will be an Ubercart product. When a user purchases that product the user's account is upgraded to a given role for a given time period. The user can also re-apply for the role by purchasing the product after end of subscription.
Prerequisites for this are an up and running Drupal installation.
1.       Create a new role for a subscription.
2.       Go to Admin->User Management->Roles(admin/user/roles)
1.       Create a new role.
2.       Set appropriate permissions for that role by going to Admin->User Management->Roles
3.       Go to Site Building->Modules (admin/build/modules/list)
1.       Enable Ubercart core modules.
2.       In Ubercart core (Optional) enable Roles module.
3.       Go to Store Administration->Configurations->Product Settings (admin/store/settings/products/overview)
1.       Under Product features->Role Assignment Settings, set the role that you have created in step 2.1 as the default role.
2.       Under Product Roles check all the roles that you want Ubercart to grant to customers who purchase specified products. If you leave all roles unchecked, they will all be eligible for adding to a product.
3.       Set the Expiration Period and other files as appropriate.
4.       Save configurations to take effects.
5.       Go to Content management->Create Content->Product (node/add/product)
1.       Create the product by filling the form.
2.       Make sure to give an appropriate SKU value.
3.       Set the appropriate prize for the product.
4.       Remember to un-check Product and its derivatives are shippable.
5.       Save the product.
6.       After saving the product, edit the product by clicking the edit tab on the product view page. Or simply by going to Content management->Content->List (admin/content/node/overview) and editing the product.
7.       Go to the Feature tab on the product edit page.
8.       Click the add button against Add a new feature and selecting Role assignment in the select box.
1.       Select the appropriate SKU of the product. Also the Role that has to be assigned to the product after purchase of this product.
2.       Make sure to un-check the Shippable product checkbox.
3.       If you want to override the default expiration period check the Override Default expiration period checkbox. Leave it as it is if you want the default expiration period to take effect.
1.       Select the end date as appropriate
2.       Select multiply by quantity if u want user to be able to purchase the product more than once and multiply the expiration date by number of time the product is purchased.
3.       Save feature.
4.       You can test the feature by logging and purchasing a product as an authenticated user. After purchasing the product the user will receive a conformation email that the user role has been upgraded for a given time period.
This is a very easy and useful way to create a time based subscription for a user.
on 24 Mar 2010 by
Amit Vyas
Sr. Web Designer and Developer

A creative man is motivated 
by the desire to achieve,
not by the desire to beat others.