I have a site where a user can watch a node using the Flag module. Users can also reference the node and I wanted to set up a rule that when the node is referenced, a message is sent to all the flagged users of the original node notifying them that the node was referenced.

Can anyone help with the rule?

  • How are you referencing? Entity reference module? May 27 '14 at 16:34
  • What do you mean by 'referenced?'
    – Hoytman
    May 27 '14 at 17:16

I would do this by creating a component of type Rule and calling this component from a separate rule that fires on one of the node save or node is updated events.

First create the component with two parameters of node type and name them "referencing_node" and "referenced_node". Create conditions Content is of type [your content type] for both referencing_node and referenced_node (this will bring in data selectors you need for the flagging user list and replacement patterns to construct your email subject and body). Next add a loop under Actions and choose the data selector for referenced_node:flag [your_flag]:user (Users who flagged the entity with flag [your_flag]) and name the list "flagging_users". Now add an action under your loop System: send mail and in your data selector for the To: field, use [flagging-users:mail] and also build your desired subject and message body from replacement patterns.

Next create a rule that calls your component with React on event: After saving new content of type [your_content_type] (you can also create a separate rule later to react on event After updating existing content however you need to build in conditions to prevent repeat email messages when no new references have been added). Now simply call your component as an action and provide your component's parameter with the variables from node (for "referencing_node") and node:your_reference_field_name (for "referenced_node").

I hope this helps you get the solution you are after.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.