I use wp_schedule_event to have the function updatePostCounts() executed every hour. I also use the plugin "WP Crontrol" which shows me that the hook (opbs_update_counts) is there and is run every hour. But when the time is due nothing happens - updatePostCounts() isn't executed. Here's the code.
public function __construct()
{
$this->addActions();
register_deactivation_hook(__FILE__, array($this, 'deactivation'));
}
public function deactivation()
{
wp_clear_scheduled_hook('opbs_update_counts');
}
public function addActions()
{
if( !wp_next_scheduled('opbs_update_counts') )
{
wp_schedule_event(time(), 'hourly', 'opbs_update_counts');
}
add_action('opbs_update_counts', array('cronTaskUpdateCounts'));
add_action('init', array($this, 'action_init'));
add_action('template_redirect', array($this, 'action_template_redirect'));
}
public function cronTaskUpdateCounts()
{
$this->updatePostsCounts();
}
what could be the problem?