emaildrupaldrupal-comments

How to send an email when a user responds to a comment


What I want is to announce the original comment poster, when someone has responded on his comment It's a bit blurry on how to do this with triggers.
Has anybody done that, or is there another way to do this?


Solution

  • I'm not sure exactly how to do it with the core Triggers module, but this can definitely be done with the Rules Module (assuming Drupal 6... not sure of any issues with Drupal 7 version of Rules).

    1. Download and install Rules

    2. Navigate to admin/rules/trigger/add to create a new rule, name it whatever you like and under the Event dropdown, choose "After saving a new comment" and click Save

    3. Click on the "Add a condition" link choose "Execute custom PHP code". In the PHP code area, add the following then click save:

      if ($comment->pid != 0) { return TRUE; } else { return FALSE; }

    4. Click "Add an action" and choose "Load comment by id". In the Comment id field add: <?php echo $comment->pid; ?> and click Save

    5. Click "Add an action" again and choose "Load a user account". In the User id field add: <?php echo $comment_loaded->uid; ?> and click Save

    6. Click "Add an action" again and choose "Send a mail to an arbitrary mail address". In the Recipient field add: <?php echo $user_loaded->mail; ?> and fill in the other fields however you like to customize the email.

    Now whenever a comment is replied to, an email will be sent to the "replied-to" comment author.