Is there any way to disable WP core updates but to have notification email sent that WP update is available to install? I know that notification email about WP update is sent after the fact when WP got updated and how to disable all (core update and notifications).
I'm trying to utilize code below:
function core_update_notification(){
global $wp_version;
$core_update = wp_version_check();
if ($core_update != NULL || $core_update !=FALSE){
$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' );
but somehow that idea is not working the way I have expected.
UPDATE #1
It looks like that wp_version_check() performs the version check, and then sets the
update_core transient if there's a new version. It doesn't return anything of value that is why code above is failing. Need to use get_site_transient('update_core')
and updated code looks like
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' );
but somehow an email is not sent