Trigger module overview
The Trigger module provides the ability to take a particular action when a trigger occurs.
Actions include functional tasks that are defined by Drupal core modules, and advanced actions that can be defined by the system administrator. Contributed modules can introduce new actions. Some examples of actions are sending an email, publishing a node, banning a user or promoting a node to the front page of a website.
Triggers are defined by modules, and typically result from some characteristic change in an entity maintained by that module. Some examples of triggers are: deleting content, adding a comment, a user has logged in, or adding a term. In addition to the triggers provided by Drupal core modules, more triggers may be added by installed contributed modules.
The Trigger module allows you to perform useful tasks by associating actions with specific triggers, such as e-mailing an administrator (the action) when a user account is deleted (the trigger), or automatically unpublishing a comment (the action) if the added comment (the trigger) contains certain words. The Trigger module is included in the core Drupal installation. The module must be enabled to use it.
The following Drupal 7 core modules define triggers that can be used to initiate actions:
- Comment: When either saving a new comment or updating an existing comment, After saving a new comment, After saving an updated comment, After deleting a comment, When a comment is being viewed by an authenticated user
- Node: When either saving new content or updating existing content, After saving new content, After saving updated content, After deleting content, When content is being viewed by an authenticated user
- System: When cron runs
- Taxonomy: After saving a new term to the database, After saving an updated term to the database, After deleting a term
- User: After creating a new user account, After updating a user account, After a user has been deleted, After a user has logged in, After a user has logged out, When a user's profile is being viewed
- configure the actions associated with triggers on the Triggers Admin page (Administration > Structure > Triggers)
- configure the available actions on the Actions Admin page (Administration > Configuration > System > Actions)
The following externally-hosted tutorials provide step-by-step guidance for using actions and triggers:
- Triggers and Actions in Drupal 7 & Drupal Gardens
- How to send email notifications for comments in Drupal 7 with actions & triggers
To define new triggers in Drupal 7, see hook_trigger_info in the Drupal 7 API Reference.
To define new actions in Drupal 7, see hook_action_info in the Drupal 7 API Reference.
Developers upgrading trigger implementations from Drupal 6 to Drupal 7 should read Trigger Overhaul.
Core module: Yes.
Related Modules: None.
API Documentation: trigger.admin.inc, trigger.api.php, trigger.install, trigger.module, trigger_test.module
Template files: None
Other files: trigger.info
Database tables (1):
trigger_assignments. Also see the API docs at trigger schema.
In Drupal 8, Trigger module has been removed from core and officially deprecated with Rules recommended as the replacement. The Trigger module in contrib exists to (one day) provide an upgrade path from Trigger to Rules.