Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Case 'Send a mail to a user' action is sellected with 'commnted content author' as a reciever the mail will be always send to the node author. This is not actualy correct due to user or site visitor may wish to comment a reply of another user and in this case the message must be send to the user of that commented post.
I've added a small piece of code that fixs a problem:
1) Change in rules_events_hook_comment_arguments() a function rules_events_argument_comment_node_author on rules_events_argument_commented_author_notify().
function rules_events_hook_comment_arguments($comment_label) {
return array(
....
'node_author' => array(
'type' => 'user',
'label' => t('commented content author'),
'handler' => 'rules_events_argument_commented_author_notify',
),
) + rules_events_global_user_argument();
}
2) Add a function iself -
/*
* Send email to the commented content author (node of comment)
*/
function rules_events_argument_commented_author_notify($comment){
if($comment->pid != 0){
//get info of previous comment author
$previous_comment = _comment_load($comment->pid);
//send email to previous comment author
$author = rules_events_argument_comment_author($previous_comment);
}
else{
//send email to node author
$author = rules_events_argument_comment_node_author($comment);
}
return $author;
}
Now it will work correct.
Comments
Comment #1
fagoComment #2
fagoComment #3
fagoPlease roll a proper patch.
Comment #4
jthomasbailey CreditAttribution: jthomasbailey commentedI can confirm this works and is a lifesaver (file to patch is comment.rules.inc, lines 69-76) if I knew how I'd roll that sucker up.
Comment #5
martin.l CreditAttribution: martin.l commentedWell, that is nice, but actually it should be possible to send an email to all other users who have commented on the same node. Just like Facebook does.
Example:
User1: author of node
Users 2-5: commented on the node, including replies to other user's comment
User6: new comment on the node or reply to other user's comment => does not make a difference if it is one or the other
Action after User 6 has commented: Mails are going out to users 1-5, telling them, that user6 has commented too on the node.
Any solution for this?
Comment #6
martin.l CreditAttribution: martin.l commentedYou can try this one. It is in productive use on www.whami.com.
I would be pleased, if this could become part of the standard module.
Comment #7
baff CreditAttribution: baff commentedsubscribe
Comment #8
mitchell CreditAttribution: mitchell commented#6 makes me sad. Ya coulda' been a patcher...
Comment #9
TR CreditAttribution: TR commentedDrupal 6 end-of-life was more than two years ago - there will be no new feature in D6 Rules, and D6 Rules is no longer supported.
That said, this could go into Rules for D7 or D8 if someone is willing to contribute code or fund the development of this feature.
Comment #10
TR CreditAttribution: TR commentedActually, comments are entities in D7 and D8. Rules integrates with ALL entities, therefore no additional explicit integration with the comment module is needed in D7 and D8 and all the code that used to be in comments.rules.inc in D6 is obsolete.
That's going on my list of favorite quotes ...