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.

CommentFileSizeAuthor
#6 3.txt1.08 KBmartin.l
#6 user_conditions.rules_forms.txt1.13 KBmartin.l
#6 1.txt1.7 KBmartin.l
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

Category: bug » feature
fago’s picture

Status: Needs review » Needs work
fago’s picture

Please roll a proper patch.

jthomasbailey’s picture

Component: Features integration » Rules Engine

I 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.

martin.l’s picture

Well, 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?

martin.l’s picture

FileSize
1.7 KB
1.13 KB
1.08 KB

You 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.

baff’s picture

subscribe

mitchell’s picture

Version: 6.x-1.2 » 6.x-1.x-dev
Status: Needs work » Postponed

#6 makes me sad. Ya coulda' been a patcher...

TR’s picture

Title: Rules does not support email sending to the user whos comment has been replied » Rules does not support email sending to the user whose comment has been replied
Version: 6.x-1.x-dev » 7.x-2.x-dev
Component: Rules Engine » Rules Core

Drupal 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.

TR’s picture

Status: Postponed » Closed (outdated)

Actually, 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.

#6 makes me sad. Ya coulda' been a patcher...

That's going on my list of favorite quotes ...