Created
August 25, 2014 07:33
-
-
Save fahidjavid/0507d425114ccd462843 to your computer and use it in GitHub Desktop.
To schedule an hourly event in a plugin, call wp_schedule_event on activation (otherwise you will end up with a lot of scheduled events!):
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
register_activation_hook( __FILE__, 'prefix_activation' ); | |
/** | |
* On activation, set a time, frequency and name of an action hook to be scheduled. | |
*/ | |
function prefix_activation() { | |
wp_schedule_event( time(), 'hourly', 'prefix_hourly_event_hook' ); | |
} | |
add_action( 'prefix_hourly_event_hook', 'prefix_do_this_hourly' ); | |
/** | |
* On the scheduled action hook, run the function. | |
*/ | |
function prefix_do_this_hourly() { | |
// do something every hour | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment