Drupal Site Configuration: Triggering Actions
The Actions section under the System section of the Drupal Configuration page shows you a list of available actions and allows you to create custom actions. An action is some event that happens in response to something. For example, when a new user registers on your site, sending him an automatic e-mail is considered an action.
The missing piece here is a way to actually use these actions. Behind the scenes, Drupal has code built-in that triggers these actions; for example, in the code for new users registering is a trigger that fires off the e-mail action.
The way you can use actions without having to write the code to trigger them is to use the Trigger module — which is an optional Core module that must be enabled before you can use it.
Here's a basic example of how to create a trigger to display a custom message to a user who signs in. You must first create a custom action by following these steps:
From the Create an Advanced Action drop-down list, choose Display a Message to the User and click Create.
In the next screen, type your message in the Message text box.
In the example, the following was typed: Hi [user:name], it's good to see you. Let's do lunch sometime.
The [user:name] is a stand-in for the name of the user who just logged in. In other words, if a user with the username Elmer logs in, after you trigger this action, that user will see the message, Hi Elmer, it's good to see you. Let's do lunch sometime.
The other half of this operation is to set up a trigger to fire off this action when a specific user logs in.
Enable the Trigger module from the Modules page.
The Triggers page has five tabs along the top. These correspond to the types of activities that happen on your site.
Click the User tab.
Because you want something to happen when a user signs on, the trigger you want is under the User tab.
Under the trigger After a User Has Logged In, select Display a Message to the User from the drop-down list.
Click the Assign button next to the drop-down list.
Now when a user logs in, he or she will see the message, with the correct username substituted for the [user:name] you put in the action.
To delete a trigger, click the Delete link next to it.