Have a look at this rule (in Rules export format), which does what you're asking for:
{ "rules_notify_commentors_about_new_comment" : {
"LABEL" : "Notify commentors about new comment",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_conditional", "comment" ],
"ON" : { "comment_insert" : [] },
"DO" : [
{ "variable_add" : {
"USING" : { "type" : "list\u003Cuser\u003E" },
"PROVIDE" : { "variable_added" : { "users_that_commented" : "Users that commented" } }
}
},
{ "LOOP" : {
"USING" : { "list" : [ "comment:node:comments" ] },
"ITEM" : { "current_comment_item" : "Current comment item" },
"DO" : [
{ "list_add" : {
"list" : [ "users-that-commented" ],
"item" : [ "current-comment-item:author" ],
"unique" : "1"
}
}
]
}
},
{ "LOOP" : {
"USING" : { "list" : [ "users-that-commented" ] },
"ITEM" : { "current_comment_author" : "Current comment author" },
"DO" : [
{ "CONDITIONAL" : [
{
"IF" : { "data_is" : {
"data" : [ "current-comment-author:field-accept-boolean" ],
"value" : "1"
}
},
"DO" : [
{ "mail" : {
"to" : [ "current-comment-author:mail" ],
"subject" : "New comment to node with id [comment:node:nid]",
"message" : "There is a new comment added to the node with id [comment:node:nid]",
"language" : [ "" ]
}
}
]
}
]
}
]
}
}
]
}
}
The only additional module needed is the Conditional Rules module, while it does use a few of the more advanced techniques available in the Rules module.
If you're familiar with reading/digesting Rules in Rules export format, I'd hope the rule is self explaining. If not here is a summary of the above rule:
- Rules Event: obvious ... after saving a new comment.
- Rules Conditions: feel free to add whatever fits (eg limit to selected content types only, like "Projects" in this specific question).
Rules Actions:
- Add a variable "
users_that_commented
" (= a list of users).
- Loop over all existing comments, and for each comment author, add that author to the list of users (=
users_that_commented
). Note the "unique" that is turned on (we do not want duplicates in that list of users).
- Loop over the list of users (=
users_that_commented
... again, which we just created and populated). And for each user in that list, do your thing, in this case "send an eMail", provided the field field_accept_boolean
is TRUE (which you can check if you have the Conditional Rules module enabled). The "To" value is crucial here, the body, the from, the title, etc is up to your own imagination. If you don't want to use the Conditional Rules module, you could also rework the Rules Action withn the last Rules Loop to performing Rules Components (in which you add the appropriate Rules Conditions), so that you don't need this extra module (for more details on that, refer to the answer to "What's the alternative to using the Conditional Rules module?").
If you want, just import the above rule in your own site (using the Rules UI), after you enabled the Conditional Rules module, and after replacing the field name of field_accept_boolean
to fit the machine name of your own field.
That's really all it takes ... a Rules variable, Rules lists and loops, and Conditional Rules.
PS: There is one minor improvement of this rule I can think of (if perfect is not good enough) ... After anybody finds out what that may be, and after the question details are corrected about that also, I'd be happy to update my answer (= change 1 detail in the rule) to also implement that.