Problem creating cron job wordpress

Here’s the minified reference I use for setting up WordPress cron, which is all from wp_schedule_event() and cron_schedules: Setup Cron // SETUP CRON add_action(‘wp’, ‘myplugin_schedule_cron’); function myplugin_schedule_cron() { if ( !wp_next_scheduled( ‘myplugin_cron’ ) ) wp_schedule_event(time(), ‘daily’, ‘myplugin_cron’); } Cron Function // the CRON hook for firing function add_action(‘myplugin_cron’, ‘myplugin_cron_function’); #add_action(‘wp_head’, ‘myplugin_cron_function’); //test on page load … Read more

wp_schedule_event will it run if timestamp has passed?

Yes, the event will trigger when the wp-cron process gets run. If something is preventing wp-cron from running, then it won’t trigger at all. If you’re having it not work, then something about your server configuration is preventing it from working. For these cases, you can generally work around them by adding this define to … Read more

WordPress scheduled task is called but not executed

I was having the same issue recently, until I followed an example from the WordPress Codex which suggests using action hooks to run the function. I think if you add the following… add_action( ‘recalculate_all_scores_hook’, ‘recalculate_all_scores’ ); …and amend the wp_schedule_event function to use the action hook name rather than the function directly… wp_schedule_event( time(), ‘fiveminutes’, … Read more

Missed scheduled WordPress

Due to your server configuration, you may need to use the alternate cron method, which uses redirect rather than http loopback. Try adding the following to your wp-config.php file: // Alternate cron method define( ‘ALTERNATE_WP_CRON’, true );

Change post status based on meta value

Your code looks okay, and considering you are not submitting user entered data, the prepare() method isn’t required, but as a matter of best-practice it’s good to learn how it works and use it consistently. With that said, using the prepare() method, your code would look like this: $sql = $wpdb->prepare( ” SELECT ID FROM … Read more

Recurring scheduled task help

You have to schedule your event in a hook, for example in after_setup_theme or wp actions: add_filter(‘cron_schedules’,’my_cron_definer’); function my_cron_definer($schedules){ $schedules[‘twomin’] = array( ‘interval’=> 120, ‘display’=> __(‘Once Every 2 Minutes’) ); return $schedules; } add_action(‘my_periodic_action’,’my_periodic_function’); function my_periodic_function(){ mail(’[email protected]’,’Test!’, ‘Test Message’); } add_action( ‘wp’, ‘wpse8170_setup_events’ ); // or add_action( ‘after_setup_theme’, ‘wpse8170_setup_events’ ); function wpse8170_setup_events() { if ( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)