Email users on node creation based on taxonomy reference I have 2 taxonomy vocabularies (town and topic) which are referenced on both a user and a node. When a node is created, I need to email all users who are referencing any of the terms referenced on the node EXCEPT when the node has been directly assigned to a user (using a User Reference field).

The Subscriptions module works great for notifying users of all new nodes with a particular term, but I cannot find a way to exclude nodes based on other fields (in my case, the User Reference).

I can use Rules to send an email when a new node is created without the User Reference, but I don't know how to define the recipients as "all users with a referenced term which is also referenced on the new  node". VBO may be the answer, but I'm lost on how to generate the View from Rules.

Any suggestions? Thanks.
Actually, you can pull up all users (or any entity) based on a field value by using the 'Fetch entity by property' action.

Since users (and nodes, and comments, etc) are all entities, you can use this action to pull up a list of users with a certain value in a field.

In your rule, that gets fired upon the update of a node, simply 


add the 'Fetch entity by property' action, 
select 'User' as the entity type, and 
in the final screen choose the field (in your case a term reference) you want to check and the specific value you're checking for.
Feel free to change the name of the entities it will fetch for you.  By default they will be called fetched_entity.


THEN, add a loop to your action set after this fetch, to go through each of the found entities.  In this loop, we'll check for your second field and exclude the necessary ones.  From what I understand, you'll want to exclude the ones whose uid matches the user reference field on the edited node.

So here's how:

By now your rule's action set should look like this: You're fetching users by your taxonomy property, then you'll looping through all the found entries (make sure it's pulling as many as you want, because it limits to 10 by default, by the way).



Now, add a component in your rules.  Components are used when you need an entirely new rule to execute in your action area.  Now that we're looping through users, we need an entirely new rule to call (IF the user doesn't have field x, THEN do y).  However, when we're in the action area, we can't call conditions.  So that's why we'll create a component that's a rule within itself, and call it from here.


Go to admin/config/workflow/rules/components or Configuration --> Workflow --> Rules --> Components
Click to "Add new component"
Select "Rule" for the component plug in.  We don't want it to be just a condition test or an action, we want it to contain both a condition and action!
Call it something like "Email non-referenced users" or something like that
We will pass it two parameters. We need to pass it the user we're currently looping through and the node that has just been changed (that triggered the rule) because we'll compare the user's uid with the node's user reference field.





Add a condition to your component that is a 'Data comparison' condition and compare the looped_user:uid (or whatever you called that incoming parameter) to the user reference field of your updated_node (or whatever you called that incoming parameter)
Careful here, make sure to check the 'Negate' checkbox at the bottom of that condition.  We want to let through only those users for whom the two fields DON'T match, i.e. the ones that aren't referenced.



 - As an action in the component, have the system send out the email you want

Voila!  Almost done.  This component now narrows down our looped users (with the correct terms) to those who aren't referenced and emails them.  The one thing we have left to do is to CALL this component in our user loop.

Go back to your original rule, and click 'Add action' to your loop (not below it, but on it)


In your list of actions, at the very, very bottom, you will see the names of components you have created.  Your new component should be there.  Just select it, and pass it the updated node and the 'fetched_entity' (which is your currently looped users) as the two parameters.

Test!

Hope this helps.