Drupal Actions and Triggers
I get some comments on this site yet I was missing some since I don't check my comments "approval queue" regularly. I want to get an email when someone posts a comment. This is easy to using Drupal actions and triggers. This is built-in functionality for Drupal 6.
- Enable trigger module in "Core - optional" fieldset on /admin/build/modules
- Create new email action:
- Go to /admin/settings/actions/manage
- Select "Send e-mail" in "Make a new advanced action available" select list and click create button
- Fill in description, recipient, subject and message fields and click save button
- Associate trigger with new action:
- Go to trigger page: /admin/build/trigger (note that it will default to node triggers)
- Click on comments tab since we want to know when comments are created (/admin/build/trigger/comment)
- For the "After saving a new comment" trigger, select our new email action from the select list and click "assign" button
- Test it! In this case, create a comment for any node and see if you get the email. If not, check your email address in the new action you created. If that is correct, make sure that you receive emails for other things on the site like creating a new account (otherwise, your system may not be sending emails at all).
That's it. Getting Drupal actions and triggers configured with Drupal 6 is easy and very useful.
Comments
Thanks
I am a Wordpress user but am researching Drupal to see if it is something I want to take the time to learn and implement for some web projects this year. This is one more helpful post about Drupal and how to make it user friendly.
Thanks for the post
Bill
http://www.billwynne.com
hey i just wanted to thank
hey i just wanted to thank you for all the useful information!!! i really needed it and this is what i needed to read. thanks again and keep on posting.
One of the few things I like
One of the few things I like about Drupal 6. The rest I don't like. Drupal almost always gives me a headache.
Customizing the trigger
I was able to set up the trigger to send emails when a new comment is posted. However, there are two places on our intranet where we use the comment feature: A suggestion box page and a project discussion page. We only want to send an email notification to the relevant group when comments are made on the project discussion page. Is this possible?
Custom triggers and actions
You could do it two ways:
1) Create a custom trigger like you suggest. I haven't created any before, but here are a couple tutorials:
http://scotthadfield.ca/2008/11/30/creating-custom-triggers-drupal
http://alexisyes.com/2008/11/19/how-write-custom-actions-and-triggers-dr...
2) Create a custom action. The action itself could be code such that it only does the action based on your requirements. After glancing at the tutorials above, this option may be simpler. Here are the hooks for that:
http://api.drupal.org/api/function/node_action_info/6
http://api.drupal.org/api/function/comment_action_info/6
http://api.drupal.org/api/function/hook_action_info/6
multiple recipients
Useful indeed. But how to send an email to more than one recipient? That would be very useful. Should I create more than one action? It doesn't work for me to enumerate different recipients...
Try commas
You should be able to put commas in between each email address in the recipient text field (not obvious but I've done this in the past and it worked).
Good luck,
Kristen
The Drupal system (6.13)
The Drupal system (6.13) won't allow it. Error message: 'Enter a VALID email address'. Not with a comma, comma-space, semi-comma... It really worked for you? No luck for me.
Tokenized email
I figured out what's up. I used it before for *tokenized* email actions. So, you'll have to enable the "token actions" module that comes with the token module and do the tokenized email action instead of the regular email action.
Good luck,
Kristen
Fabulous
Now I know when to check my site. Thanks so much.
Will I get an email?
I am posting this comment to see if I get an email sent to me. Posting (saving) this comment is the trigger. The email that is sent is the action.
is there a way...after
is there a way...after someone posts a comment, to check if the comment contains a list of keywords and if so...then send an email?
Custom action
I haven't seen a way to configure that through the UI, so you'd probably have to create a custom action for that. They are easy to do if you know how to program in PHP.
http://api.drupal.org/api/function/node_action_info/6
http://api.drupal.org/api/function/comment_action_info/6
http://api.drupal.org/api/function/hook_action_info/6
Good luck,
Kristen
Got it!
Post new comment - ALL COMMENTS ARE MODERATED - SPAM WILL BE DELETED!