scheduled event in Wordpress


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. if (!wp_next_scheduled('my_task_hook')) {
  2. wp_schedule_event( time(), 'hourly', 'my_task_hook' );
  3. }
  4.  
  5. add_action( 'my_task_hook', 'my_task_function' );
  6.  
  7. function my_task_function() {
  8. wp_mail('[email protected]', 'Automatic email', 'Hello, this is an automatically scheduled email from WordPress.');
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.