Triggers

The trigger module is a very powerfull and flexible module that enables actions to be fired on certain system events. For example: sending an email to the administrator (action) when an anonymous user saves a comment (trigger). So, the module works in close relationship with Actions.
To understand how Triggers and Actions work, it might be usefull to follow the the example.
It's logic that, to trigger actions for certain events, some modules must be enabled. To trigger actions for
- comments, the comment-module must be enabled.
- taxonomy, the taxonomy-module must be enabled.
Other modules enhance the possibility to trigger actions. The token-module for example enables to build up actions with textual placeholders, like [title] for node-title or [user] for user-name.
In order to use Trigger, you have to enable the module under core-optional. No permission has to be set.
Managing actions
All the management for Actions is done on the Action-page (Administer>>Site configuration>>Actions). In the text above the actions, there's a link towards Triggers that you can follow after adding or changing actions.
There is a list of actions available to Drupal where, by default, some simple actions like 'Publish post' are displayed. You add actions by going to Make a new advanced action available.
Advanced action
The choice of advanced actions that is available depends of the modules you enabled (see Token above). Choosing an action and clicking Create brings you to the page where the action can be modified.
Managing Triggers
You manage triggers on the Trigger-page (Administer>>Site building>>Triggers). On top you see a list of for what you can assign a trigger for. In the text, you find a list to the Action-page that you may follow to administer Actions, and under the text a list of what you may set triggers for.
Example of Trigger
Email somebody automatically after a user saved a comment.
Modules that have to be enabled: Trigger, Comment
Action (Administer>>Site configuration>>Actions)
Under advanced option, choose Send email..., click Create
- Description: change to 'send email to administrator after user saved comment'. One action can be used by several triggers, so, if you want, you can call it 'send email to administrator', but then you might have a problem with the message-part, specifying what it's about.
- Recipient: the address you want to send the email to. In this case the administrator.
- Subject: write "A comment has been saved" (without ")
- Message: write: "%username has saved a comment about %title. The link to the page is %node_url" (without "). %username, %title and %node_url are variables that will give you the username, title of and link to content where the comment has been made. Under the body you can find other variables you might use in Actions.
Save
In the list Actions available to Drupal, you should see now send email to administrator after user saved comment, with links to configure or delete the action.
Trigger (Administer>>Site building>>Triggers)
Go to Comments and choose Trigger: After saving a new comment. On the list, pick System: send email to administrator. Click Assign
Modifications
It's obvious that, with minimal modifications, you can trigger that an email is send to anybody you want after another event, like when a new user-account has been created.
- Add new comment
- 713 reads

