How to notify users when a new comment is posted in the same page as they did? I have a Drupal 7 website and I display comments on a content type.

What I want, is for every user to have a boolean field in their profile, to declare if they want to be notified when a new comment is posted at the content type that they posted.

I tried the Comment Notify module, but it shows its options right before you post your comment, and doesn't have a use with user profile/field.  

I have already achieved a similar notification, for the user to be notified when the administrator replies to one of the user's comments.

I managed it using the Rules module, before a comment is posted, with these Rules Conditions:


Entity has field (comment:parent:author) and Data Comparison, to verify a relevant boolean at the user profile.
Data Comparison, for the (comment:author:roles) to be administrator.


Although, I can't seem to achieve the requested rule.

I know I have to do a search for every commenter at the same node, before a comment is posted, if they have the boolean enabled at their profile, but I can't create it with Rules.

To sum up, I have a content type (projects) and I have created about 50 of them. If some user X posts a comment on one of the projects and has the boolean enabled, then if anyone else comments on the same project, user X will be notified by email.

Any help?
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&#39;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.