Hi all,

On my site there is a node-type called "Project". In each "Project" node there is a (date) field called "Expiry date" and another field (boolean) called "Expired?".

What I need is a function that is executed every day that simply updates the "Expired?" field to TRUE of all projects which have passed their "Expiry Date" that day.

I have spent a long time today trying to find the best way of doing this. I cannot find answers to the following questions:

1. I think I need to write an Action for this - am I right?
2. If so do I really need to write an entire module just to hold the action - if not where else can actions be put? eg. template.php?
3. Once my Action is set up how can I call it from within cron.php?
4. Are there any simpler ways to do this?

Thanks for any help you can offer, I really appreciate it.

Ben Jackson

Comments

grendzy’s picture

Yes, as small module would be a good way to do this. It might look something like this:

/**
 * Implementation of hook_cron().
 */
function mymodule_cron() {
  db_query("UPDATE {content_type_mytype} SET field_expired = TRUE WHERE field_expiration_value > NOW()");
}
dpearcefl’s picture

Status: Active » Closed (fixed)

Closing this issue for lack of response. And the provision of a good solution.