I'm using the SMSFramework module for my user validation, I have a rule which changes user role to "Confirmed" when the user approves his cellphone number.

That means then, every node that the user have must become Published. I have no idea how to implement this with just using rules!

Since my event is: After updating an exisiting account it means I have no access to the users's nodes! that I can get some actions fired on them!

I'd really appreciate your help.


Yes this can be done with the Rules module. Here is a summary of what you'll need to get it to work:

  1. Keep track of all node IDs of a user that still need to be published later on (after the user approves the cellphone number). For this add an entity reference to the user's profile (multiple values allowed). And each time such unpublished node get's saved you need to add the reference to that node as an extra value in this entity reference field (= Rule 1). So basically this is the "queue" of nodes for a user that need "post processing" after the user approves the cellphone number. It is will serve as your entry point starting from the user's id to "access (find) the exact node ids again later on".

  2. Create a rules component (= Rule 2, though of type "component") with parameter just a "node id". All this Rules component has to do, is to "publish" the node indicated in the parameter. But you can add any Rules "Conditions" also if you'd need any (already now or later on if requirements change). E.g: check that the node is not published yet, only for specific content types or user roles, etc.

  3. Create a rule (= Rule 3) containing a Loop that should be triggered after the user approves the cellphone number. The goal of this rule is to loop over each of the nodes in the reference field from Step 1, and in each iteration of that loop you use an action which is to invoke the Rule Component as detailed in Step 2 (and which uses the node id as a parameter). By using a Rules Component, you'll be able to add any "Conditions" you might need inside the "Loop".

Video tutorials

If you're not familiar (enough/yet) with using Loops in rules, then watch the video about List and loops.

For a video that is fairly similar to what's needed in step 2 and step 3, refer to the 2nd video (= Solution video) about Creating multiple back links. Some more details about how your scenario slightly differs from what is shown in that solution video:

  • You are creating an entity reference to nodes also, but from a user (not a node).
  • You only need the first parameter (= Node to link to) in your Rules component (you don't need the 2nd parameter).
  • Thanks as usual Pierre, It will take me a bit of time to finish what you suggested, let me get started with it and I'll let you know if I managed to pull that off or not! thank you again – user23288 Aug 31 '15 at 9:12
  • 1
    Thanks for the feedback. Yes you may need some time to digest this. After you get this going (learn how to do things like loops, etc in rules), you'll probably find other use cases of Rules. That's why I more and more try to replace all sorts of specialized contrib modules functionalities with yet another Rules variation, typically as part of my set of modules that is only Views / Rules / Flag / Message / Organic Groups / PrivateMsg / Content Access / VBO (maybe I forget a few more here) ... – Pierre.Vriens Aug 31 '15 at 9:40
  • Hey Pierre, sorry for responding so late, I tried your approach, it's going well, but I have an issue for when I fill my entity reference field with author's nodes, it's not selected, it's being generated by views, so it's more like a list, and I still need to select those nodes automatically and I have no idea how to do that. – user23288 Sep 8 '15 at 10:09

Your Answer

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