Quantcast
Channel: drupal.org - Site administrators
Viewing all articles
Browse latest Browse all 426

Tutorial 18: Role upgrade/downgrade based on user activity

$
0
0

Introduction:
In this example we want to add to an authorized user a specific role. In this example we want to add the role of “Contributing Member”.
Why? The idea is that a user’s role is changed based on certain actions he / she performs. Let’s say a user adds contents and for this she / he receives a bonus by upgrading the role allowing the user to do / access more content.
In my example the user creates an entry in a database and by adding the information the user acquires the right to see the full database with all the entries of other users.
This could be time-limited (3 months or so) to encourage the user to update or add more database entries – this would be another rule based action.
The background is:
User log in to the site as basic members (authorized users). If they want to see the database of “Patterns” they need to become Contributing Members. The only way to become a Contributing Member is by sharing their own work / knowledge in form of adding a “Sample”.
These “Samples” are in a database based on Content Type “Pattern Sample” containing various CCK fields including an image sample of the pattern, etc.
The database is made available through Views as a table with the restriction to role “Contributing Member”.

Actually this example also works for all other types of roles you may already have created on your site. Let’s say you have a role for premium members. Following this example they would also need to have to add an example to get access to this database. While this may be useful to boost the database it might be against your terms of use giving premium members free access to all information. If this is the case you will have to either configure the access to the database (Views – in this example) or define the rule below so that the premium members are not subjected to the rule – you just need to add another condition. You also need to carefully manage the permission settings in either case.

Add triggered rule to upgrade a role from authorised user to Contributing Member:

1. Go to the triggered rules page ("admin/rules/trigger") and click on "Add a new rule".
2. Fill out the label with "Add user role {triggered rule}" and select "Node|After saving new content" from the event box.
3. Hit "Save changes" to create the rule. On the resulting page click "Add an action", where we will schedule our rule set.
4. Select "User|Add a user role" from the select box. Now choose the user that should be upgraded – Label – “User whose roles should be changed:” the choices are:
• acting user
• content’s author
Both would be correct – though we stick to acting user in case. In your project this may be different if you want only the author to be upgraded but not users changing 7 adding the content of this node.
Now choose the role you want the “acting user” to upgrade to – here “Contributing Member”.
5. Now add a Condition. Only after saving a Content Type “Pattern Sample” shall the user be upgraded.
6. Click on “Add a condition” and choose “Node|Content has type”
7. Confirm the action by clicking "Next".
8. From the list select Content Type “Pattern Sample”
9. Confirm by hitting “Save”


Viewing all articles
Browse latest Browse all 426

Trending Articles