WordPress.org

Ready to get started?Download WordPress

Forums

wp_next_scheduled() returns null but wp_options 'cron' shows my event (2 posts)

  1. matt_price
    Member
    Posted 2 years ago #

    Hi,
    I have the following code in a simple plugin, which is supposed to register an action when the plugin is loaded:

    // run tablecache_activation on plugin registration
    register_activation_hook(__FILE__, 'tablecache_activation');
    
    // create an 'action' that will run once
    add_action('cache_coursetables', 'uothelper_updatecoursetables');
    
    function tablecache_activation() {
      // this method only registers via the plugin registration interface
      if ( !wp_next_scheduled( 'cache_coursetable' ) ) {
        wp_schedule_event(time(), 'twicedaily', 'cache_coursetables');
      }
    }

    When I look direction in the wp_options table of my database, the value of 'cron' is reported thus (added some line returns & bold to make it easier to read):

    a:7:{i:1327964590;a:3:{s:16:"wp_version_check";a:1:
    {s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:17:"wp_update_plugins";a:1:
    {s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}s:16:"wp_update_themes";a:1:
    {s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}}i:1327964604;a:1:
    {s:19:"wp_scheduled_delete";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:5:"daily";s:4:"args";a:0:{}s:8:"interval";i:86400;}}}i:1327986895;a:1:
    {s:18:"cache_coursetables";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:10:"twicedaily";s:4:"args";a:0:{}s:8:"interval";i:43200;}}}i:1328018823;a:1:
    {s:24:"akismet_scheduled_delete";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:5:"daily";s:4:"args";a:0:{}s:8:"interval";i:86400;}}}i:1328019676;a:1:
    {s:17:"wp_db_backup_cron";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:5:"daily";s:4:"args";a:0:{}s:8:"interval";i:86400;}}}i:1328029548;a:1:{s:10:"ai1ec_cron";a:1:{s:32:"40cd750bba9870f18aada2478b24840a";a:3:{s:8:"schedule";s:5:"daily";s:4:"args";a:0:{}s:8:"interval";i:86400;}}}s:7:"version";i:2;}

    However, the event doesn't seem to be running, and
    wp_next_scheduled('cache_coursetables') returns the empty set. Is there something obviously wrong with my code?

    Thanks much for you help!
    Matt

  2. Stephanie Leary
    Member
    Posted 1 year ago #

    You've probably figured this out by now, but it looks like you have a typo:
    if ( !wp_next_scheduled( 'cache_coursetable' ) )
    should be
    if ( !wp_next_scheduled( 'cache_coursetables' ) )

Topic Closed

This topic has been closed to new replies.

About this Topic