HowTo: Configuring Triggers and Actions in Drupal 6
By Gerard McGarry on 3rd April 2008, filed in Drupal, Web Applications. Both comments and pings are currently closed. Tags: Drupal, Tips

Drupal 6 offers built-in actions that can be performed whenever something happens on your site. Typically, you want to use this to get an alert when someone publishes content on the site, or a new user signs up.
You might even want to mimic WordPress and get an email alert every time someone leaves a comment on the site. I’m going to show you how to set this up for your site.
Defining Triggers and Actions
First, let’s take a look at what triggers and actions actually are. A trigger is an event which will happen on your site. Triggers that I can see on my site are Comments, Content, Cron, Taxonomy and Users.
If you look at the available triggers for Comments, you’ll see various trigger types. The one we’re interested in is “After saving a new comment”.
Before you can activate a trigger, you need to specify an Action. This is the action you want to happen each time a trigger is ..er.. triggered. You can do a number of things with actions, such as redirect users to a URL or give them a message on the page. However, we’re mostly interested in the Send Email action.
Step By Step Instructions
OK. So let’s set up a simple action and trigger combo to send us an email each time a comment is left on our Drupal site.
- Before you start: Make sure you’ve got the trigger module activated. Browse to Administer -> Site Building -> Modules and check that Trigger is enabled. If not, switch it on, obviously!
- Now, let’s set up our action – browse to Administer -> Site Configuration -> Actions. Drop down the Make a new advanced action box and select Send e-mail. Click Create.
- Set up your alert email with an easy to recognise Description and Subject – I used “New Comment on [Sitename]” for mine. Enter the email address of the person who’s supposed to receive the alert (probably you) and then enter a short message – you should see some variables underneath the text field showing variables you can use.
- Save your changes et voila, your action is configured. Now to attach it to a trigger…
- Browse to the Trigger page in Adminster -> Site Building -> Triggers. Click the Comments tab and drop down the list underneath After saving a new comment. You should see your email in the list – select it and click Assign.
- Job done – your action has been configured.
Don’t Forget To Test
You didn’t think we were finished yet, did you? Now you need to test that the triggers are working correctly.
Just to approach this as a regular site visitor, log out of your Drupal site. Or, if you’re smart like me, just fire up another web browser where you’re not logged on to the site (that way, you can still use the admin part of Drupal in your main browser and test the average user experience in the other).
Simply visit any blog post on the site (or any node that allows comments) and leave a comment on that post. Now, head on over to your email inbox and wait for that alert to arrive. Mine arrived in just a couple of minutes.

Great stuff! Why don’t you publish your posts on Drupal Planet? http://drupal.org/planet
I’d be flattered to be a part of Drupal Planet, especially because I don’t think there are enough easy to grasp tutorials for the platform.
Any idea how to get included?
This is a great tutorial. I’m curious whether you’ve been able to set up something similar to comment notify – http://drupal.org/project/comment_notify – with Drupal 6. I’d really like both the node author and anyone that has left a comment to receive an email update when someone makes a new comment on a node. I can get the node author part working, by setting the recipient to “%author” – but I can’t figure out how to also alert anyone that has commented on the node. If you have any ideas, I’d love to know!
Thanks again for sharing this tutorial.
Hi Doug – glad you liked the tutorial!
As for doing comment notification for readers, I don’t think the triggers and actions features can go as far as the notify plugin – you’re basically restricted to a manually entered email address.
As well as that, there’s no way to get the consent of the other commenters. You’d ideally want an opt-in button so that people can choose to subscribe to comments. You’re probably better off with the Notify module to be honest.
Nice and simple, perhaps too simple.
I am trying to find out how to email notify a page is changed and the flag translation as outdated checkbox is unticked.
Any Ideas
Is it possible to use the Trigger module to trigger a change in User Role upon activation? I would like to be able to promote my users to new roles after completing a quiz.
Is there any way to make a role change a trigger. My client has a database of users, some of them lapsed clients, who are blocked users. When they register for his conference, he changes their role from blocked to active and adds a role. When that happens, he’d like it to automatically trigger a modified version of the first registration letter, including password and basic instructions. So far all we can figure out to do is delete the existing user and re-add them, which is insanely cumbersome. Any suggestions?
How can I trigger an event on a node “Publish”??
I have a setup where anonymous users can submit articles, but they are approved by the admin. The admin schedules the approved articles for future publish. I need to send a tokenised email to the user when the article is published.
This seems to be a fairly basic requirement, but i cant seem to find how to do it. I had this working fine in drupal 4.x.
Please help.
Hi,
When using actions and triggers on Drupal 6 I (the admin) get an email notification even when I post a comment with the admin user account, do you know how to disable this ? I don’t want to be notified of my own comments.
Thanks a lot.
Is it possible to trigger an action based on a date in a content record? For example, suppose I have created a content type called “Projects” that includes a Date field called “Deadline”. I want to be able to send an email when the current date is equal to the value of the date in that field — or better yet, when the current date is X days before the deadline date. If the latter isn’t possible, I could always add another field called Reminder Date and have the trigger look at that field…
Thanks!
I am trying to use the triggers on drupal 6 and have setup an action. When users are logged in I want to redirect them. I specify a node/xxx but it doesn’t work.
I have also tried the login destination module and put this code in to direct users.
global $user;
if ($user->uid == 1) {
// Redirect the Administrator
return ‘admin’;
} elseif ($user->uid == 2) {
// Redirect the Site Owner to the ‘create content’ page
return ‘node/add’;
} elseif ($user->uid == 3) {
//redirect sti users
echo uid;
return ‘node/xx’;
} else {
return ‘node’;
}
I have event tried to specify a static URL using login destintation.
That doesn’t work either.
Ideally I need to redirect users according to roles but a simple redirect per user if it worked would help.