I need to send an email when there is a new comment on a node to all users that have flagged that node? How do I do this?
The flag is called "Follow" and the content type is "Blog"
The exported code assumes use of Flag module to have a flag type as "follow" attached to Blog content type.
As a summary:
Here is the export for my Rule configured as per your requirement.
{ "rules_email_on_blog_comment" : {
"LABEL" : "Email On Blog Comment",
"PLUGIN" : "reaction rule",
"TAGS" : [ "blog", "email" ],
"REQUIRES" : [ "flag", "rules", "comment" ],
"ON" : { "comment_insert--comment_node_blog" : { "bundle" : "comment_node_blog" } },
"DO" : [
{ "flag_fetch_users_node" : {
"USING" : { "flag" : "follow", "node" : [ "comment:node" ] },
"PROVIDE" : { "users" : { "users" : "Users who flagged" } }
}
},
{ "LOOP" : {
"USING" : { "list" : [ "users" ] },
"ITEM" : { "list_item" : "Current list item" },
"DO" : [
{ "mail" : {
"to" : "[list-item:mail]",
"subject" : "New Comment",
"message" : "There is a new comment on the flagged blog post",
"from" : "[site:mail]",
"language" : [ "" ]
}
}
]
}
}
]
}
}
You can use a loop to get all the users who have flagged, and you can add an action to send mail to all those users under that loop.