Unpublish node based on date field with Rules

by nihilistenhymne   Last Updated January 09, 2018 10:07 AM

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.

Tags : 7 rules


Answers 1


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).

If the above is not what is causing your issue, then it's time for Rules debugging ...

Pierre.Vriens
Pierre.Vriens
January 09, 2018 10:05 AM

Related Questions


Clone nodes and change fields with Rules and VBO

Updated May 20, 2015 20:03 PM