drupaldrupal-7drupal-commerce

Drupal 7 - Run rule on every user triggered by cron


Is it possible to run a rule on every user triggered when the cron runs.

I need to check every users subscription stutus (commerce subscription module) and if the subscription has expired downgrade their role.

I was hoping the module had this feature but apparently not.

Can this be done?


Solution

  • Sure, make your rule as normal, write a small custom module and implement hook_cron() to run rules_invoke_event().

    function MYMODULE_cron() {
      rules_invoke_event('rule_name', $arg1, $arg2, $argN);
    }