php - wp_schedule_event hook scheduled but not working -


i'm trying trigger cron job wordpress plugin i'm writing (it's gonna take new products , export them csv every day) problem when i'm put code in functions.php working great , code valid plugin folder it's scheduled , can see (with cron view plug-in) not executed.. found same questions there no answer.. seems it's not been triggered or blocking it.. take @ code..

function csv_init(){ add_action('my_hourly_event', 'download_csv_with_args'); }  function starthere(){ // code here     $file = $_server['document_root'].'/wp-content/csv_settings.php';                             $content = serialize($args);                             file_put_contents($file, $content);                          wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'my_hourly_event');                              $schedule = wp_get_schedule( 'my_hourly_event' );                             echo  wp_next_scheduled( 'my_hourly_event' ).'<br>';                         if ($schedule){                             echo '<h3>the "'.$schedule.'" cron job running..</h3>';                          }else {                             echo '<h3>there no cron jobs running..</h3>';                          }  }  function download_csv_with_args() {         //execution of code } 

try move add_action outside of function:

function starthere(){   if (!wp_next_scheduled('my_hourly_event')) {     wp_schedule_event( time(), 'hourly', 'my_hourly_event' );   } }  add_action( 'my_hourly_event', 'download_csv_with_args' );  function download_csv_with_args() {   wp_mail('you@yoursite.com', 'automatic email', 'cron works!'); } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -