Using Trigger module in Drupal 6
In this post I will show you how to use Trigger module to perform useful tasks in Drupal 6. The Trigger module provides the ability to trigger actions on system events, such as when a new comment is created/saved or when a new user updates his/her profile.
By combining different actions and events its possible to perform complex tasks such as automatically blocking a user along with e-mailing an administrator and unpublishing his/her comment if he/she has used restricted keyword(s). By default, there are five categories of events which can be fired upon when a certain action takes place.
- Categories
- Content
- Comments
- Cron
- Users
More categories can be added by additional modules.
I will take up a very basic task to show you how to use Trigger module. Suppose we want to display a welcome message to the user when he/she logs on to our website. To do this follow the steps given below.
- Enable the trigger module if you haven't done so. It is by default provided with Drupal, you don't need to dwonload it. To enable the trigger module, go to Administer -> Site Building -> Module, select the trigger module from the list of modules and click on save as shown below.
- Go to the Admin section. Under the Site Configuration you will find the Actions option, click on it.
- On the Actions page scroll towards the end of the page and under Make a new advanced action available section, choose Display a message to the user... from the dropdown list and click on Create.
- Now enter a description and message(which you want to display when a user logs-in) and click on Save.
- Go to the Admin section and click on Triggers under Site Building. On the Triggers page select Users in the tab as shown below.
- Now under Trigger: After a user has logged in section, select the action which you had created above and click on Assign.
Thats it! Now lets test it .Logout and then login again. You will be see your custom welcome message as shown below.
Similarly you can perform more complex tasks, by using Trigger module, as discussed in first paragraph.