How to create membership website?

Posts: 11
Joined: 02/14/2008

Hi,

I tried to create a membership website which offering several levels of memberships.
For example:
- 24 hours membership, only valid for 24 hours.
- 7 days membership, only valid for 7 days.
- 1 month membership, only valid for a month.
- 6 months membership, only valid for 6 months.
- 1 year membership, only valid for a year.

For information, I do not allow anonymous transaction, so every buyer has to create an account to make a transaction.

Here are what I have done:
1. Created 5 new roles for each memberships.

2. Created 5 products for each memberships and associated the above roles with them. I also set up the expired date.

3. So far, everything is working perfectly. But there is problem when someone has already bought a membership (e.g. 1 month membership) and would like to upgrade it to the higher level (e.g. 6 months membership). Since the first role has not been expired, if he/she purchases a new one, there will be multiple roles assigned to the same user. I do not want it like that.

4. To handle the above problem, I then created several workflow-ng configurations. For every completed transaction, I checked if there is any existed roles for that user (of course I excluded "authenticated user" role). If there is, I remove it. So far so good, but then I realized a trouble. The workflow-ng only removes the role, but not the expired date of that role! How can I remove the role as well as its expired date using workflow-ng?

Posts: 332
Joined: 08/07/2007
Administrator

Functionally, this shouldn't matter. Expirations on user roles do nothing other than remove the role (and email a notification if set) upon a cron run. Since this might bother people, I've added an update to bazaar that will remove expirations during a cron run if its found a user no longer has a role associated with the expiration.

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

Posts: 11
Joined: 02/14/2008

Thank you Shawn. You are correct, it really bothers me since everytime my members log in, all their roles are listed. These include the roles that have been removed.

The other reason is because I have activated the email notification. I do not want my members complaining because they got a confirmation email about role that is no longer theirs.

Posts: 11
Joined: 02/14/2008

Shawn, I have another question.
Suppose I want to create another type of membership level, let's name it "guest". This membership is automatically assigned to a new user who registered, and only valid for 24 hours. How can I do that?

I was thinking to create a new product (and make this product free of charge), then assigned the "guest" role to it. I also set its expiration time to be 24 hours. The problem is, how to make it automatically assigned (gave) to a new user within the registration process? I looked in the workflow-ng actions, and there is no choice for this purpose.

Posts: 332
Joined: 08/07/2007
Administrator

You will have to create a custom module that makes use of hook_user when $op == "insert". This will be called when a user account is created. From here you can make use of the function _role_action($op, $user, $rid, $timestamp = NULL) in uc_roles.module (open up the module and you can see how it works). This function, when $op == "insert", will add a role specified by $rid to the user object $user with an expiration of $timestamp (a UNIX timestamp that represents the date of expiration).

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine