I am using a Loop in Actions to generate a list of email recipients.
This list is based on a reference field in the node.
The field is generated from a view and is based on the node author's 'friends' (friended via the user relationship module). The node author has selected which friends can view the specific node when created.
I have a child action under the loop to email the friends the node author has selected--via the reference field--for this node. The rule in general is triggered when the node or comments are created or updated.
Everything works dandy except that if I am a friend (and not the node author) and I create or update a comment, I also receive (in addition to the other selected friends) the email notification.
Any suggestions on what I can do to suppress the email to myself in this situation? No one wants to receive emails on their own updates. Typically I can put a condition in place to suppress. However, I can't put conditions on the loop itself which runs after the rules conditions. And it doesn't seem like I can pass the loop variables to a component for further evaluation on each item in the loop.
I am looking for a solution in which no coding is required. I would like to use the frameworks without coding.
Thanks!
Comments
Creating a child component
Creating a child component with its own conditions for sending the e-mail should work. Not sure why that isn't working for you.
You could also loop over the list twice, once to remove the current user and once to actually send the e-mails. Make sure you make a copy and/or don't update the actual field.
Or you could use Conditional Rules (http://drupal.org/project/rules_conditional) to nest more conditions in your loop.
Thanks krlucas. 1) Before I
Thanks krlucas.
1) Before I go for Conditional Rules module I am trying to loop over the list twice as you suggest. I added an action to the loop--before the send mail action--which will remove item from list. However, this has removed the item from the actual node field. So I added an action after the send mail to add the user back. However, this does not seem elegant and actually changes the update time of the node itself.
Are you able to provide a little more clarity around: 'Make sure you make a copy and/or don't update the actual field.' as I don't see those options.
2) Also regarding: "Creating a child component with its own conditions for sending the e-mail should work. Not sure why that isn't working for you."
I haven't been able to get this to work because the list variable from the original loop in the reaction rule is only available for child actions there (like send mail action directly nested under the loop). So if I move my send email action to a component action that I make a child of the reaction rule loop, I am not able to access the list item data from the reaction rule's loop -- in specific I need the list item's email address. When the send mail action is directly nested in the loop in the reaction rule, the variable is available as a token to use for the TO address of the email. But it is not available in the component. I set component variables but I can't find anything that will let me pass the list item value through to use as a token in the email message TO field.
Thanks.
For the record I've only got
For the record I've only got experience with Rules 2 in Drupal 7. So if this is Drupal 6 none of this may make sense.
1)
-Add an action outside the loop to Add a Variable of type List of Text or List of Users or whatever.
-Create a loop over the original list/field.
-Add an action inside the loop to Add an Item to a List. The list is the variable you created, the item is current_item in the loop.
-Add an action after the loop to Remove an Item from the list. Remove the current user from the variable you created and populated.
-Add a final loop over the created variable to send the e-mails
2) You should be able to pass any data object in the parent rule to the component as a parameter. When you create the component (of type "Rule") you can choose the data type, whether it be User, a node or text or whatever. Just like in a reaction rule you may need to add a condition of "Content is of type" or "Entity has field" to make sure you see your custom fields in the actions.
Thanks again. I am using D7
Thanks again. I am using D7 for this site.
I gave up and installed conditional rules module and was able to accomplish the goal in 10 minutes. I wish I posted this comment 2 days ago as I didn't realize that module existed :) So thank you for introducing it.
Also, thanks for the explanation in 1) above. I will give it a try later. I am positive others can benefit from your explanation.
Thank You.
No problem! But don't thank
No problem! But don't thank me, thank fago, klausi, zhangtaihao, and mitchell.
Conditional Rules has been really solid in my experience.