Posted by ultimike on February 27, 2009 at 9:02pm
Hello, I'm in the process of building a site that sells tickets to events using ubercart. I'd like to be able to have a rule that automatically unpublishes the event node when the event date passes.
For the most part, I've been able to do this but there's still a question in my mind as to whether or not I've done it the best way. Here's a quick synopsis of what I did:
- Created an "event" content type (actually an ubercart product class).
- Added a date field to the "event" content type (field_dates).
- Created a rule that is run on cron.
- I did not include any conditions.
- For the rule's action, I wrote a snipped of PHP code that queries the node table or the published nodes of the "event" type that have a field_dates value in the past and unpublished any that it found.
Is this the best way of accomplishing this using the Rules module?
I've attached an export of the rule in case anyone is interested.
Thanks,
-mike
| Attachment | Size |
|---|---|
| unpublish_events_rule.txt | 1.28 KB |

Comments
use the built-in scheduling mechanism
Once the node is created/updated schedule a rule set to be executed on the given time. So then rules executes the given rule set on the given time for you. So you don't need any custom code. Probably this needs to be documented better, so if someone could do a tutorial for that ,that would be just awesome.
However currently the docs are broken :( http://drupal.org/node/376790