I need to create a plugin to conditionally update the status on all entries in a channel each day based on a date field. I don't think I need to interact with a template in this case, so would want to call the plugin directly via cron.

What I'm looking for are any example plugins that might lessen my learning curve in how to get and loop through all entries from a channel and conditionally update the status based on the date?

3 Answers 3


You would actually want to use a module for this, so that you can have an action ID associated.

The module development documentation section about the install method mentions how to setup action IDs, which basically allow you to load http://yourdomain.com?ACT=123 from a cron job and run a method from your module.

From there you simply need to build out your module method. It sounds like your operation is fairly simple, and so you can probably just use the CodeIgniter active record class to query for the correct entries to deal with and then update the statuses accordingly.


An alternative: if you're comfortable having a script outside of EE access your database, you could write a simple-ish SQL update statement, and have your cron run that script.

The SQL would be something like this:

update exp_channel_titles
set status = 'new status'
where entry_date > 1385943600 and channel_id = 1

If you're using a "custom" field for the date, then you'll need to do a join, like

update exp_channel_titles a join exp_channel_data b 
on a.entry_id = b.entry_id
set a.status = 'new status'
where b.field_id_123 > 1385943600 and a.channel_id = 1

Your field_id_123 will be the internal name of your custom field--it's just the field's ID number tacked on to field_id_.

PHP for accessing the database (again, outside of EE), looks something like:

$db = new mysqli($db_hostname, $db_username, $db_password, $db_name);
if ($db->connect_errno) {
   die('Failed to connect to DB');



I think you already have your answer but if you need an additional reference (albeit an old one) then take a look at the CRON job EE page template code for the 'Paid Members' extension, you drop this into a EE template, enable PHP and then call it using a CRON job.


It's EE1.x stuff but again might be useful as a reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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