Cron Job variable not accessible

First of all, it’s best not to include wp-blog-header.php. Instead, set the cron job to your homepage URL with a ?mycustomcron=true variable appended (eg: http://example.com/?mycustomcron=true. Then we will check for the existance of this variable when the page loads: function wpse_103127_check_cron() { if ( isset( $_GET[‘mycustomcron’] ) ) { // things to do on cron … Read more

Refresh page using Cron after any post is published

Well, I don’t think you can do this with cron. Browser sends request to server and gets response. It isn’t connected permanently to your server. So if you want to refresh page which is already displayed in browser, you have to force browser to send request for this page one more time (do refresh). Another … Read more

How can I prove if wp cron is running my task if I have DISABLE_WP_CRON set to true

I always found that logging cron job execution to a file is very helpful. Otherwise you have no idea if it’s working right. Just have your code open a file, write a timestamp, and close. Something simple like: $logfile = $_SERVER[‘DOCUMENT_ROOT’].’/CRON.txt’; $handle = fopen($logfile , ‘a’) or die(‘Cannot open file: ‘.$logfile ); $data=”cron task called … Read more

wp_schedule_event action not running

I think your problem may be in the use of $post->ID. In your code $post is an undefined variable. As you are inside a loop, try get_the_ID() instead of $post->ID: $post_ID = get_the_ID(); $request_start_time = get_post_meta( $post_ID, ‘_simple_start_date’, true ); if (date(‘Ymd’) == date(‘Ymd’, $request_start_time)){ $current_user = $post->post_author; $request_date = get_post_meta( $post_ID, ‘_simple_start_date’,true ); $request_year … Read more