Wp Maintenance mode and external cron job

You can use the wp_doing_cron() method to determine if the request comes from a cron request or not. if( defined( ‘IN_MAINTENANCE’ ) && IN_MAINTENANCE && $pagenow !== ‘wp-login.php’ && ! is_user_logged_in() && ! wp_doing_cron() ) {

wp_schedule_event only when admin is visited

In your event callback function check to see if the user id the admin then run the function else just reschedule it. So using the example from the codex’s page you linked in the question it would be something like this: function my_activation() { if ( !wp_next_scheduled( ‘my_hourly_event’ ) ) { wp_schedule_event(time(), ‘hourly’, ‘my_hourly_event’); } … Read more

Schedule cron don’t work

You shouldn’t call wp_clear_scheduled_hook on every page load, because then you’re always restarting your wp-cron shcedule, with your current setup. Additionally this call: wp_clear_scheduled_hook( ‘le_do_this’ ); doesn’t make any difference, since le_do_this isn’t a hook name in your setup. You could try for example this test plugin: <?php /** * Plugin Name: Daily WP-Cron * … Read more