Last updated August 29, 2016. Created on September 8, 2007.
Edited by mlncn, ashish_nirmohi, dddave, Fiable.biz. Log in to edit this page.

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.

Drupal 7

The following Drupal 7 core modules define triggers that can be used to initiate actions:

  1. 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
  2. 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
  3. System: When cron runs
  4. Taxonomy: After saving a new term to the database, After saving an updated term to the database, After deleting a term
  5. 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

You can:

  • 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:

  1. Triggers and Actions in Drupal 7 & Drupal Gardens
  2. How to send email notifications for comments in Drupal 7 with actions & triggers

Developers

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.

Drupal 6

Drupal 6 core defines triggers that can be used to initiate actions. The triggers available in Drupal 6 core are grouped into the following categories:

  1. Comments: After saving a new comment, After saving an updated comment, After deleting a comment, When a comment is being viewed by an authenticated user
  2. Content: When either saving a new post or updating an existing post, After saving a new post, After deleting a post, When content is viewed by an authenticated user
  3. Cron: When cron runs
  4. Taxonomy: After saving a new term to the database, After saving an updated term to the database, After deleting a term
  5. User: After a user account has been created, After a user's profile has been updated, 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

You can:

  1. configure the actions associated with triggers on the Triggers Admin page (Administer > Site Building > Triggers)
  2. configure the available actions on the Actions Admin page (Administer > Site Configuration > Actions)

The following externally-hosted tutorials provide step-by-step guidance for using actions and triggers:

  1. How to Configure Triggers and Actions in Drupal 6
  2. Triggers and Actions in Drupal 6

Developers

To define new triggers in Drupal 6, see hook_hook_info in the Drupal 6 API Reference. For a detailed example, see writing Drupal 6 triggers in the Drupal Module developer's guide for Creating Drupal 6.x modules.

To define new actions in Drupal 6, see hook_action_info in the Drupal 6 API Reference. Developers should also read the Drupal 6 handbook page on writing actions.

Technical details for Drupal 7

Core module: Yes.
Dependencies: None.
Related Modules: None.
Permissions: 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.

Drupal 8

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.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.