Disable WP core updates but send email notification

It looks like after switching code to check get_site_transient('update_core') I have got what I need just action must be executed in a proper priority or a hook (thoughts/suggestions?). Working code below:

function core_update_notification(){
   global $wp_version;

   $installed_version = $wp_version;

   $uc_transient = get_site_transient('update_core');
   if ( empty($uc_transient->updates) ) return;
   $updates = $uc_transient->updates;
   $current_version = $updates[0]->current;

   if (version_compare($installed_version, $current_version, "<")) {
      $to = "[email protected]";
      $subject = "WP update is available!";
      $message = "You have WP update ready to install";
      $headers="From: My Website <[email protected]>" . "\r\n";

      wp_mail( $to, $subject, $message, $headers );
   }

}

   add_action( 'init', 'core_update_notification' );
   add_filter( 'auto_update_core', '__return_false' );

I think the best solution it will be to use daily wp_schedule_event in that case following steps from here: https://codex.wordpress.org/Function_Reference/wp_schedule_event

Leave a Comment

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