Created
June 24, 2012 20:59
-
-
Save ekka21/2984925 to your computer and use it in GitHub Desktop.
Wordpress: corn job
This file contains hidden or 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
//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