I have a custom content type "project" with several CCK fields. One of them is named "field_old_intranet_url". No i want to assign a (random) user to every node of type "project". The author field or any other user_reference would be fine.

My first thought was to create a rule which is triggered when a user logs in. Fetch X random "projects" without an author and save the current user as the nodes author.

The problem is, that you can either fetch nodes by id or property. nid is not working, since i dont know the id. When fetching by property one can only compare the property with data from the current user or the current page. In my opinion it is not possible to fetch X random nodes.

Another solution would be, to trigger the rule by content creation or when content ist saved or whatever and then assign a random user. But this isnt possible either, because you cant fetch X user without a property to compare.

I hope my problem is clear and you can come up with quite different solutions!

Edit: It is possible to fetch every possible combination of X nodes of whatever type with Views Bulk Operations. This part of the problem is solved. Now the remaining challenge is to assign one entity of one of the lists (users / nodes) to a random one from the other, is this possible?

One solution would be to fetch a random node using views, is this possible?

3 Answers 3


Investigate the Views Module. It can create lists of nodes for you. Investigate node_load() and node_save(). They will allow you to modify those nodes.

  • Can i access the lists in the rules module? I'm a configurator, i haven't done any coding with drupal.
    – jumper
    Commented Dec 16, 2011 at 18:50
  • perhaps, if you know php code, but this, to me at least, is a coding issue, not a drop-in to rules. hopefully someone out there has some more info for you.
    – Jimajamma
    Commented Dec 16, 2011 at 19:03

It is possible to fetch every possible combination of X nodes of whatever type with Views Bulk Operations.

To create the desired behaviour you can follow this set of steps:

  1. In the actions part of a rule you fetch a list of nodes (list_projects) using VBO, to which a random user should be assigned.
  2. Using the sorting option "Global: Random" you can fetch one random user inside a loop and assign him to the other list of nodes.

I don't know pf a pure config solution. However this can easily be done with a few lines of code in hook_node_api (D6) or hook_node (D7).

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.