In User management, go to the Roles administration and create a new user role. Call it trial user, for instance.
Creating a rule set as a scheduling action
- Go to "admin/rules/rule_sets" and click on the tab "Add a new rule set".
- Fill out the label with "Expire user role {rule_set}".
- In the Arguments fieldset, on the first row select "User" as data type, enter "User {argument}" as the label and "user_argument" as the machine name.
- Press the "Save" button to continue.
- You are redirected now to the rule sets overview page and your freshly created rule set is listed.
- Click on the "Expire user role {rule set}" label and add a new rule by clicking the "Add new rule" tab.
- Fill out the label of the new rule with "Expire action {rule}" and click on "Save changes".
- You are now on the edit page of this rule. We want to add an action by clicking on "Add an action".
- Click on the "Select an action to add" drop down, choose "Remove user role" and then click Next.
- Select the role you created in the initial preparations - trial user, and click Save.
Creating a triggered rule
- Our simple rule set is now completed and is ready for scheduling.
- To trigger the rule set we need to invoke it on a certain event, so we go to the triggered rules page ("admin/rules/trigger") and click on "Add a new rule".
- Fill out the label with "Expire rule {triggered rule}" and select "User account has been created" from the event drop down box.
- Hit "Save changes" to create the rule. On the resulting page click "Add an action", where we will schedule our rule set.
- Select "Schedule Expire user role {rule set}" from the select box and confirm the action by clicking Next.
- Now we adjust the scheduling information: Append "{action}" to the label at the top.
- Under "Arguments configuration", select "registered user" from the drop down. The difference between "registered user" and "acting user" is registered user is the actual new user account that is created upon signup whereas acting user is the user account that is used to perform the task. In the case of a new signup, this user is the Anonymous user.
- You must enter a value in the Identifier text field. This will show up in the scheduled rule sets task list and so you can enter a value that will refer to the user. Enter "User [account:user]" which will result in the new user's login name being listed in the scheduled rules task list.
- Enter a date or value in the "Scheduled evaluation date" text box below. You could put a value such as "+7 days" to schedule the expire role task to run in 7 days time.
- Click save and your triggered rule is now set up.
Testing
At this point we are ready to do a little test.
- Either logout of your Drupal installation or fire up another browser and go to the signup page (user/register).
- Create your new user and return back to your administration account to confirm.
- go to the rule set scheduling page ("admin/rules/rule_sets/scheduling"). You can see now a task entry in the task list that contains a scheduling date in 7 days and the identifier is set to the username of the new user.
No comments:
Post a Comment