Closed (fixed)
Project:
Rules
Version:
6.x-1.1
Component:
Rules Core
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
24 Feb 2010 at 09:56 UTC
Updated:
23 Aug 2017 at 07:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
betoaveigaIt didnt work for me :(
Comment #2
mortenson commentedFOund any solution for this?
Comment #3
summit commentedSubscribing, greetings, Martijn
Comment #4
Hunabku commentedOK i implemented a fairly complete comment notification solution based on rules - it is not that complex and "so far" i'm very happy with using Rules instead of comment notification modules. Note: I made the titles of the rules, actions, etc. long and descriptive to help in your understanding. Also you can implement this by manually adding rules and their elements - and/or - by importing the attached triggered rules and rules set. Either way make sure the two sending email actions have the values you want in them.
To handle all comment instances (not just someone replying to an existing comment) be sure to have a triggered rule for notifying the node author that a comment has been posted. The rule is triggered on the event: "After saving a new comment". PS so that the node author is NOT notified when they make a comment/reply for their own node, be sure to include a negated php based truth value condition:
echo ($user->uid == $node->uid );Add an action "Send a mail to a user (Commented Content Author)". To import the above mentioned rule see attachment "Notify_node_author_of_comment.txt"Create a new rules set called "Notify parent comment author set". Give it three arguments: User, Content and Comment. After clicking "Save" you'll be able to add a rule to this rule set. Add one called "Notify parent comment author" then add three "truth value" conditions to it. The first condition we'll call "Check a truth value (Parent Comment exists)" - its truth value field is simply: [comment:comment-cid]. The next one called "Check a truth value ($user->uid == $comment->uid)" is negated, ie should have a "NOT" displayed before it, since we don't want to send an email if the user is replying to their own comment. Call the last condition "Check a truth value ($node->uid == $comment->uid )" which is also be negated since we don't want to notify the node author if a user is replying to one of the node author's comments, notification would be redundant since an email was already sent to the node author with our very first triggered rule "Notify node author of comment". Finally, add an action called "Send a mail to an arbitrary mail address (Parent Comment Author)" - make the recipient [comment:comment-author-mail]. You can have the subject be something like: [user:user] replied to your comment [comment:comment-title-raw] for post [node:title-raw] at mysite. For the message body try: To view comments please go to http://mysite.com/[node:node-path]#comment-[comment:comment-cid]. To import the above mentioned rule see "Notify_parent_comment_author_set.txt"
Now we have to create another triggered rule that will in turn DO the previously created rules set. We'll call this triggered rule "Load parent comment and do Notify parent comment author set". The rule is triggered on the event: "After saving a new comment". This rule will have two actions: The first one is called "Load comment by id (Comment Parent ID)". Load the parent comment via
echo $comment->pid;For the second action, select Rule Set: "Notify parent comment author set (Acting User, Commented Content, Loaded Parent Comment)". Set three arguments for the action: "User:Acting User", "Content:Commented Content" and "Comment:Loaded Parent Comment". Just so you know, the parent comment (loaded in the first action) is passed to the rule set - along with other two objects/arguments. To import the above mentioned rule see "Load_pcom_do_notify_pcom_author_set.txt"Haven't got a chance to test this all extensively - but so far so good.
see: Imaginariums - habitats for co-creating our dreams
Comment #6
skizzo commentedThank you Hunabku. I am trying to implement notifications without additional specific modules and your Rules recipes work nicely. Not all users in a "thread" will be notified, but that may be acceptable... In case others are interested, I also added a "Notify flag" (per node, users can flag/unflag their own and other's nodes). Flag module has Rules integration, so I could easily add a "if flagged by author" condition to the Notify_node_author_of_comment rule. If anyone succeeds adding a similar condition to Load_pcom_do_notify_pcom_author_set or Notify_parent_comment_author_set please share! (the purpose would be to notify the comment's author only if he/she so desires). Thank you.
Comment #7
baff commentedGreat!
I also want to avoid notification+messaging module
Here a rule which sends email to node author when a new comment is made
Comment #8
baff commentedSorry file was empty - here the right one
Comment #9
baff commentedPlease post your rules here: http://drupal.org/node/1120898
Comment #10
baff commentedTried #4 but get an error, see file attached
Comment #11
itangalo commented@baff: What is the 'argument' things that are not loaded? Is that when Rules tries to load the parent comment?
Comment #12
baff commented@Itangalo - yes - parent comment id
php echo $comment->pid; does nor work for me
parent comment id is always empty whatever I try.
Where or how to request a parent- comment token?
Comment #13
itangalo commentedI downloaded the rule you posted here, but couldn't see how it was supposed to notify the author of the parent comment. I built a new rule, that does this -- see attachment.
The attached rule has some limitations:
* It requires the PHP Filter module, since it has PHP in configuration. This should not be used on live sites. (You should also be aware that it requires Token.)
* It doesn't verify that there *is* a parent comment, which will lead to error messages when there isn't. To get rid of those you'll have to make a rule set where the first rule tries to load the parent comment, and the second one checks if this succeeded and, if so, sends a message.
That's it for today,
//Johan Falk
I'm a part of the Rules Issue Squad, helping out in the issue queue. You can join, too!
Comment #16
baff commentedThis rule gives an error on import in my system
Did someone test the rules posted here? They do not work on my system. Parent Ids always empty.
PS: a [parent-comment-pid] token would be very helpful
Comment #17
baff commentedHere is the debug output
Comment #18
itangalo commented@baff: The error message above seems to imply that there is no parent comment. Are you really using comments in a tree structure? (The 'previous' comment is not automatically a parent comment.)
Comment #19
baff commentedYes Tree structure, see screenshot attached
Comment #20
baff commentedI forgot to activate php filter module on my test site ....
Working - Thanks
Comment #23
mitchell commentedUpdated component.
Comment #24
yesct commentedNote the tag guidelines: Before adding tags read the issue tag guidelines. Do NOT use tags for adding random keywords or duplicating any other fields. Separate terms with a comma, not a space.
Comment #25
sam-elayyoub commentedhere is the solution for replying comment using only rules, just import this rule and change the subject and body only
regards
sam.
Comment #26
nekooee commentedthank you
------------------------
https://www.farazit.com
https://www.irantk.ir