Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #27087


Ignore:
Timestamp:
02/10/2014 08:00:35 PM (11 years ago)
Author:
TobiasBg
Comment:

You are mixing up "hook" and "callback" here. wp_schedule_event indeed requires a string as the "hook", in the sense of plugin action hook. You can then attach a "callback" (usually a function or class method) to that action hook:

wp_schedule_event( time(), 'daily', 'my_unique_plugin_event_hook' );
add_action( 'my_unique_plugin_event_hook', array( $this,'hook' ) );

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27087

    • Property Status changed from new to closed
    • Property Resolution changed from to invalid
    • Property Milestone changed from Awaiting Review to
  • Ticket #27087 – Description

    initial v1  
    1 wp_schedule_event will not accept array() for the hook (must be string). As such, wp_schedule_event( time(), 'daily', array($this,'hook') ); will not work, however, moving the hook method outside of the class will work as the $hook is no longer an array.
     1`wp_schedule_event` will not accept array() for the hook (must be string). As such, `wp_schedule_event( time(), 'daily', array($this,'hook') );` will not work, however, moving the hook method outside of the class will work as the `$hook` is no longer an array.