Why would a scheduled cron show up in admin but not in wp-cron?

I created a new plugin in wordpress, which schedules a cron when it is activated. The scheduling part looks like this:

    $crons = _get_cron_array();
    //Use wp_next_scheduled to check if the event is already scheduled
    $timestamp = wp_next_scheduled('customers-hourly');

    if($timestamp == false) {
        //Schedule the event for right now, then to repeat daily using the hook 'wi_create_daily_backup'
        wp_schedule_event(time(), 'hourly', 'customers-hourly');
    }
    $crons = _get_cron_array();

    add_action('customers-hourly', [$this, 'hourlyCron']);

When stepping through the code with the debugger, after activating the code, _get_cron_array contains this:

$cron = [ // 12 elements
    [.. snip other crons ..]
    1493335692 => [
        'customers-hourly' => [
            'schedule' => 'hourly',
            'args' => [],
            'interval' => 3600,
        ],
    ],
    'version' => 2,
];

So my cron is definitely there.
When I load up the cron.php directly and _get_cron_array() is called, it shows 19 elements, none of which are the customers-hourly.

Any idea what is causing this?

Read more here: Why would a scheduled cron show up in admin but not in wp-cron?

Leave a Reply

Your email address will not be published. Required fields are marked *