Hi all,
I'm trying to unpublish nodes of a certain type x days after their creation date.
This action should happen every time cron is run.
In big letters, events should be automatically unpublished 30 days after their creation date without needing someone to actually do something on the website.
I've been following this process : http://groups.drupal.org/node/240678
But if I understand well, this will only happen when a new node is created.
If I set the event to "Cron maintenance tasks are performed", I cannot use the node in condition or action.
Can someone tell me if Rules module can do that, and how?
Thank you!
Comments
Comment #1
tobiasbCreate a view and add a field from vbo (http://drupal.org/project/views_bulk_operations).
In rules you load this view in a action while cron runs. create a loop for this list. Then add a component with conditions which checks this bundle of the entity and the date. And a action unpublish the entity. This component do you use in your loop of your normal rule.
Comment #2
ludo.rThanks for the tip!
I will try this very soon! :)
Comment #3
ludo.rHi,
Sorry for the delay.
I have tried your solution and followed this tutorial : http://nodeone.se/en/using-vbo-to-load-list-of-objects-into-rules
But I don't know why it worked the first time, then I published the nodes again and then the rule did not work anymore. The view still returns correct results, but nothing happens.
I ended up by coding a quick cron job myself.
I let this issue open in case someone encounters the same problem.
Thanks anyways!
Comment #4
ericwongcm commentedIf anyone is trying to do the same, another way I found is creating a view to "show" those nodes you want to unpublish by filtering them by Node: Creation date (< -7 day)
https://drupal.org/project/views_rules
Comment #5
liquidcms commentedsorry for completely hijacking this thread (title, making a bug, etc)... but pretty much the same issue and this has been inactive for 10 months..
i eventually found a great tutorial here: #1386746: Set a data value of an item in a list provided by VBO comment #16.. which i understand, makes sense and should work.. but the very basic first step of this is failing.. get a list of items from vbo view.
without the complexities of the component to set a field value, etc... the simple Rule is this:
event: cron task
condition: my vbo list has at least 1 item
action: show a message
run cron.
if the condition is part of my rule the msg never shows even though views preview shows a result. if i delete the condition; the msg shows.
Comment #6
liquidcms commentedi have narrowed my issue down a bit and i think best to start a new issue.. vbo/rules integration has a bug but likely not specific to this..
Comment #7
tr commentedA VBO to select all nodes, run periodically from cron, is a pretty inefficient thing to do.
A better way is to use the Rules scheduler. React on the event when the node is created, and use the Scheduler action to schedule the node to be unpublished in 30 days.