11/20/2023 0 Comments Cron job every 15 minutes![]() The best way to run WordPress cron is to set define('DISABLE_WP_CRON', true) in wp-config.php file and then run the cron from system crontab as described in this post. So you must convert them back to numbers when passing the argument to the wp_next_scheduled() function.įor more information, check the documentation: This is important because, sometimes people save the arguments in database as key value pairs, & when they use it again later, the value from database doesn't work for arguments that were numbers, as the numbers are converted to strings when retrieved from database. For example, in the following CODE, $args1 and $args2 are NOT the same, but $args1 and $args3 are same: $args1 = array( 'key' => 1 ) Register_activation_hook( _FILE_, 'wpse_custom_cron_plugin_activation' ) įunction wpse_custom_cron_plugin_activation() Īgain, remember, it has to be the exact same argument, even different data type will not work. schedule the cron event on plugin activation ![]() ![]() 'display' => esc_html_( 'Every Fifteen Minutes' ), The plugin CODE will be something like the following: 15 * 60, The other one will be one time cron event that'll run at 9PM. Note: for the simplicity of implementation, all time entry in the CODE is considered to be GMT/UTC.įor this, you need to schedule two cron events, one will start at 6PM and keep running at every 15 minutes from 6PM. ![]() Let's say you want to start the cron at 6PM and keep running the cron after every 15 minutes till 9PM (for 3 hours). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |