Guest User

My Cron Job Code

a guest
Jul 31st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. //I have created my plugin which will get input from form and below code will run  
  2.         //My Code to create events
  3.         //hookname = gh_post
  4.         wp_schedule_event( $next_run, 'fifteen_minutes', $hookname, $args );
  5.         $cron_stop_time = $next_run + 180;
  6.         $hookname_stop = $hookname.'_stop';
  7.         wp_schedule_single_event( $cron_stop_time, $hookname_stop, $args);
  8.  
  9. //I put this in functions.php
  10.         add_action('gh_post_stop','gh_post_stop_callback');
  11. function gh_post_stop_callback($args)
  12. {
  13.  
  14.     update_option('touched_cron','stoped');
  15.     while( false !== wp_unschedule_event( wp_next_scheduled( 'gh_post' ), 'gh_post' ) ) {}
  16. }
Add Comment
Please, Sign In to add comment