The Goal

I am working on a way to shut off access to all nodes of a given type by setting their Content Access permissions to off, after a certain date has passed (and presuming that their access levels are not presently set to not allow anyone to see them, as I don't want this to trigger every time the rules run in a date range). Rules + Content Access was suggested to me in the #drupal IRC channel, but I'm not totally sure it is going to work.

What I've done so far

  • I have added a rule to be triggered when Cron Maintenance tasks run.
  • I added a "Data Comparison" rule to check site:current-date and see if it is past a certain value.

The Issue

When I go in to add the action of "Revoke Access By Role", I do not have the option to set on which content types I want the access revoked by. In fact, the only option in the selector is site:.

I have also attempted to add a node condition, but there is also no way to select any node fields, presumably because it's wanting to act on whatever triggered the event (i.e. Content Updated in the case of nodes), and since I've selected a cron I only have access to the site: parameters.

My Question

Is there a way to tell rules to change the content permissions for all nodes of a content type via a cron maintenance run, or will I need to write a custom method to be triggered via the rules condition? (Or a completely separate module for that matter).

  • Which access do you want to "shut off" is it view, edit and delete? Commented Feb 12, 2013 at 7:12
  • 1
    You have to load the nodes before you can change them (with a loop). I would probably be just unpublishing them with a rule instead of stuffing around with access permissions.
    – 2pha
    Commented Feb 12, 2013 at 8:44
  • @DavidThomas - All access, actually. I don't want anyone besides administrators to view, edit, or delete.
    – Cthos
    Commented Feb 12, 2013 at 18:18
  • @2pha - It's not the individual nodes I want to restrict access to, per se, I want to eliminate the ability to create/edit/view nodes of that type.
    – Cthos
    Commented Feb 12, 2013 at 18:19

2 Answers 2


A proposition:

  1. Enable "Rules Sheduler" at /admin/modules.
  2. Go to /admin/config/workflow/rules/components and create a component
    • Add new component:
      • Component plugin => Action set
      • "Continue"
    • Component plugin:
      • Specify the component name (e.g. Revoke node access component)
    • choose in the table:
      • Data type => Content
      • Label => Node:Component or Node or what you want
      • Machine name => node_component or node or what you want
      • Usage => Parameter
      • "Continue"
    • Add actions:
      • Select actions to add => Revoke access by role
      • Data selector: is set as node-component by default; this is the selector name you have specified in the table in the step above
      • In "Role-based access control settings" check roles you want to revoke access for view/edit/delete content
      • "Save"
  3. Go to admin/config/workflow/rules and add new rule (Add new rule):
    • Add new rule:
      • specify the rule name (e.g. Revoke node access rule)
      • React on event => After saving new content
      • Restrict by type => optionally, choose a node type you want to apply this rule to
      • "Save"
    • Events:
      • (optionally) you may also add here "After updating existing content" event if the rule has to triggered on existing nodes
    • Conditions:
      • (optionally) add your additional conditions here
    • Actions:
      • Add action
      • Select the action to add => Schedule component evaluation
      • Component: Select yor component you have already created (Revoke node access component)
      • Continue
      • Scheduled evaluation date:
      • click the "Switch to data selection and specify" button and specify:
        • Data selector: node:created (or other date-based condition)
        • Add offset: optionally specfify an offset for the chosen data selector (e.g. 1 seconds)
      • Identifier: Specify an identifer ("A string used for identifying this task") which is visible (Rules) "Scheduler" (/admin/config/workflow/rules/schedule) and in "Recent log messages" (/admin/reports/dblog). You may use tokens/replacement patterns.
      • Node:Component:
      • Data selector => node
      • Save

What's this?

This solution triggers a rule after a new and/or existing node has been saved. The rule "schedules" the component with an action set - in our case, the action is to revoke node access to the checked user roles. After content has been added as new and or edited, the component revokes node access on nodes for specified roles as scheduled on cron run, e.g. adding new article now +1 sec makes it unaccessible (view/edit/delete) on next cron on > (node:created +1 sec).


It is also possible to add Schedule component evaluation as an action into a component. For example: you want this rule to be triggered using node:changed date, so every time you edit a node, the date for the action "Revoke node access" will be moved forward (e.g: node is changed now => the rule triggers in 1 day (offset in component settings); the node will be changed tomorrow, so the rule will be trigerred on tomorrow date +1 day and so on).

You can import and test the component:

{ "rules_revoke_node_access_component" : {
    "LABEL" : "Revoke node access component",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "content_access_rules" ],
    "USES VARIABLES" : { "node_component" : { "label" : "Node:Component", "type" : "node" } },
    "ACTION SET" : [
      { "content_access_action_revoke_node_permissions" : {
          "node" : [ "node-component" ],
          "permissions" : { "value" : [


You can import and test the rule:

{ "rules_revoke_node_access_rule" : {
    "LABEL" : "Revoke node access rule",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : { "node_insert" : [], "node_update" : [] },
    "DO" : [
      { "schedule" : {
          "component" : "rules_revoke_node_access_component",
          "date" : { "select" : "node:created", "date_offset" : { "value" : 1 } },
          "identifier" : "Revoke node access",
          "param_node_component" : [ "node" ]

You should create rule invoked by cron run, list all nodes what you want to change and in loop for every node set permissions you want.

  • But can you create that from the rules interface, or do you have to create that in a module?
    – Cthos
    Commented Jun 30, 2013 at 23:28

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.