Skip to content

Instantly share code, notes, and snippets.

@ekka21
Created June 24, 2012 20:59
Show Gist options
  • Save ekka21/2984925 to your computer and use it in GitHub Desktop.
Save ekka21/2984925 to your computer and use it in GitHub Desktop.
Wordpress: corn job
//You probably know that WordPress can schedule events.
// In this recipe, I’ll show you how you create an event that will be executed once hourly, or daily, etc.
if (!wp_next_scheduled('my_task_hook')) {
wp_schedule_event( time(), 'hourly', 'my_task_hook' );
}
add_action( 'my_task_hook', 'my_task_function' );
function my_task_function() {
wp_mail('[email protected]', 'Automatic email', 'Hello, this is an automatically scheduled email from WordPress.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment