I have a certain content type in which I have a user entity reference select list that is invisible to users/editors.

The idea is that the creator of the request has to choose a role of employees to who he sends this node, and then the other users can either accept or reject it, and only if ALL employees reject, the node would actually go to a rejected state, unlike the usual way of working with workbench.

To do this, I have the invisible user-entity reference field. Now I want to achieve the following:

  1. When creating the node, after save, I want the reference field to automatically select all the users of the chosen role
  2. By clicking a button 'reject', I want to remove the current user from the selected list.
  3. When no users are selected, the node gets rejected.

Option 2 & 3 are easily done with rules. However, phase 1 is where I'm struggling. So I have the complete list of users, but now I have to "select" them, which I can do with rules by using "add to list". However, the selector only gives me the options "entities" and "site", in which site only includes "current-user", "current-page" and "feed-node".

How can I make it select all users of a certain roles?

2 Answers 2


It appears to me that there is a straight forward solution to have your rule process all those users of a certain role (as in your question): you could an approach to process the results of a VBO enabled view via Rules, whereas your rule performs 2 Rules Actions:

  • load the VBO list of users that you want to be processed (= those users of a certain role).
  • add a loop to perform a Rules Action, probably similar to the rule you already have in place, for each user contained in your Views results.

For more details, have a look at the tutorial "How to process the results of a VBO enabled view via Rules?".


Would "Fetch entities by property" work? You could select all users of role and add them to the list.

There is another option of doing a custom action. Just query the database for users with the right role, and then add those results to the field. It's been a while since I have done that, but I believe it requires a join to get it to work properly.

  • Thank you for the response, but I've found a different way of doing it just 1 hour ago. I have combined it with an SQL import that I have created, and I do the check through an event on SQL, and then inject an import node which updates the content type through rules & then deletes the import node again after usage. To do this, I had to work the other way around, as mentioned, I do have the current user, but not the users from a role. So I now add the users that rejected, and then do the check on the roles through a query. Nov 19, 2015 at 17:17
  • Great! Glad you got this figured out!
    – lukedekker
    Nov 19, 2015 at 17:48
  • Found an even better solution, so I didn't need the SQL import solution, as that would create new nodes (they get deleted afterwards, but still make the nid go up while it's not needed). I was able to achieve the same by making the reject solution, that adds the employees to the list, save the entity at the end in its rule, and then made a second rule on entity save, where I have a PHP condition with my SQL query check, and there I continue the rest. :) Much cleaner solution, completely done inside of Rules :) Nov 19, 2015 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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