I'm trying to unpublish a node based on a date field with Rules. I've followed this tutorial but somehow it doesn't seem to work.

Here's my Component:

{ "rules_unpublish_termin" : {
    "LABEL" : "Unpublish Termin",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "node" : { "label" : "node", "type" : "node" } },
    "ACTION SET" : [ { "node_unpublish" : { "node" : [ "node" ] } } ]

And here's the Rule:

{ "rules_unpublish_termin_rule" : {
    "LABEL" : "Unpublish Termin Rule",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : { "node_insert--termin" : { "bundle" : "termin" } },
    "IF" : [ { "node_is_published" : { "node" : [ "node" ] } } ],
    "DO" : [
      { "schedule" : {
          "component" : "rules_unpublish_termin",
          "date" : [ "node:field-termin-datum:value" ],
          "identifier" : "Unpublish content ID [node:nid] ([node:title]).",
          "param_node" : [ "node" ]

I'm fairly new to Drupal and I've never used the Rules module so I'm not sure if there's something else I'm missing here.

I've been looking into it a bit more. Currently I have 3 nodes in this bundle with the following dates: 2018-01-09 (which should have been unpublished today)

In the Tab Schudule under admin/config/workflow/rules/schedule I can see that the component rules_unpublish_termin has a Schedule Date for 2018-07-14 00:00 which would correlate with the very last date, this seems a bit odd..

1 Answer 1


1. Timing of a scheduled Rules Component

After a rule is scheduled (using the Rules Scheduler, a submodule of Rules), it will only actually execute next time cron runs. Example:

  • schedule a rule to execute at timestamp X (which appears to be node:field-termin-datum:value in your case).
  • if the next time that cron runs is at Y mins after timestamp X, then the Rules execution will only happen then (= at Y mins after timestamp X).

BTW, as per the edit of your question, it seems that the Rules Component actually does get scheduled, and that your real issue is related to the execution of that scheduled component ... read on for more details about that.

2. Cron runs anonymous

Cron (always) runs with user anonymous, rest assured about that (in any Drupal 7 site). But here is an "educated" guess: your site is configured so that anonymous users are NOT allowed (= do not have the permission) to unpublish nodes.

Up to you to confirm if my guess is correct, but if it indeed applies, the answer to your question is that to get this to work you would need to grant anonymous users the permission to unpublish nodes. I bet it is not going to be what you want to do (I wouldn't ...), but trust me, that would be a prereq to make it all work in your site.

3. If everything else fails ...

If none of the above helps to find out what is causing your issue, then try either of these suggestions to get a better understanding of what is (not?) happening:

  • Try to execute your Rules Component "manually" (just to test), to unit-test if it works as desired, so without using the Rules Scheduler. To do so, use the "execute" link to the right of the Rules Component (in the Rules UI).

  • Do some Rules debugging ... For way more details about that, refer to the answer to "How can I display the value of a variable inside a condition?".

  • Thanks, Pierre! I just edited my question to add a detail, maybe this helps to discover the issue here. I'm just trying to debug my rule. Though even after running Cron manually it didn't unpublish my node. Commented Jan 9, 2018 at 12:02
  • @nihilistenhymne as per your edit of your question, I also further improved my answer. I'm about sure item "2." of my answer is going to be the actual answer to your question ... at least an explanation for why it is not working as you would want to. Let me know ... Commented Jan 9, 2018 at 12:42
  • thank you for your valuable answers! I've been looking through it again and is it possible that because of "IF" : [ { "node_is_published" : { "node" : [ "node" ] } } ], this Rule only applies for nodes that are created and published after I created the Rule? Commented Jan 9, 2018 at 17:32
  • 1
    hey @nihilistenhymne, the logic described in your question, will only apply to termin-nodes that (a) were created (= your Rules Event) AND (b) with status published (= your Rules Condition) AFTER you enabled your Rule (and for as long as you leave the Rule enabled). I.e. only for such nodes your Rules Component (to unpublish them) will be scheduled (to run at the specified date). You remember since when your Rules is "active"? Also: what is the creation date of each of those 3 nodes? Commented Jan 9, 2018 at 18:01
  • Pierre, you saved me, thank you. I didn't understand the Conditions to this extend. Commented Jan 19, 2018 at 11:44

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.