HIRE US

Let us help you with your Drupal requirements

To prevent automated spam submissions leave this field empty.

Triggers and Events are very important concept in the Drupal world. If you want to get your hands dirty tweaking Drupal or dive into Drupal development or simply configure a Drupal website properly you need to be familiar with the Drupal Actions and Triggers. If you want to know more about Drupal Triggers and Actions then read on to find out.

Introduction

Triggers are events occurring in a Drupal system. A node getting published or a new user getting registered are good examples of Drupal Triggers. When these events (Triggers) are activated, Drupal allows us to perform custom operations within that context. These operations will be defined in functions and these functions are what we refer to as Actions. Triggers and Actions can be considered as pairs, but they are more than that since we can call one or more actions per trigger. Actions can also be assigned to multiple triggers.

One of the advantages with Triggers-Actions concept is that a Drupal user with zero coding experience can assign Actions to Triggers without modifying the code. Think about a scenario where the site admin wants to send a custom email when a user logins to their Drupal site for first time. The admin can select an Action that will send a custom email for the Trigger - user login, Moreover using Triggers and actions we can implement customizable complex workflows within Drupal.

Triggers

Triggers have to be defined within Drupal code. By default, Drupal 7 has several predefined Triggers. To see the Triggers within your Drupal installation go to the Admin page Structure -> Triggers (Trigger module needs to be enabled). You will see tabs for each category of Triggers. System, Node, User modules have Triggers by default.

Actions

Actions are functions that perform some operations on or using system objects, eg. entities like nodes, users, comments etc. So Actions will acting on some context containing some system object(s). Actions are of two types: ?Basic and Advanced. Basic Actions just work without any configuration. Advanced Actions needs to configured before using it. That means, Advance actions are customizable, they will have their own configuration forms.

To see the Actions in your Drupal installation, go to Configuration -> Actions page. You will see all Basic Actions listed there by default. Advanced Actions have to be created by configuring them. You will see a 'Create an advanced Action' form at bottom of the that page. By selecting one of the advanced Actions and pressing the 'Create' button you can create the advanced Action after completing the configuration.

Assigning Actions to Triggers

Admins can assign Actions to different Triggers. Each trigger can have multiple actions associated with it and each actions can be assigned to more than one Trigger.

Hope the article made you familiar with Drupal Actions and Triggers. Stay tuned for Part 2

Post your comments / questions