1

I'm using drupal 8 and the scheduler module to automatically unpublish custom content after x days have passed.

While unpublishing a boolean field from the custom content needs to be enabled/disabled.

So far I tried rules module after_a_node_has_been_unpublished_by_scheduler with Condition: Entity has field with Action: Set a data value Unfortunatelly the action does nothing.

What else could I try?

  • 2
    are you specifically looking for a non-code based solution (like rules)? Because if you are comfortable coding you should be able to do this with a simple hook_node_update implementation since the node is saved at the time it is (un)published with scheduler – bleen Mar 1 '17 at 14:28
  • Thank you for the idea. I used hook_node_presave because hook_node_update did not save the change. I've isolated the unpublished node by testing for $node->original->get('status')->value and $node->get('status')->value. – J. Dough Mar 2 '17 at 12:02
-1

You can create your custom code in a hook_cron, and you can handle your verifications following the date of publication.

  • I would not use this solution. You are creating a situation where the scheduled state change and the boolean field change the poster is looking to make are completely decoupled. This can cause one to happen without the other in a specific cron run – bleen Mar 1 '17 at 14:30

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.