WordPressのコア自動更新が成功した際のメール通知を停止し、失敗(エラー)時のみ通知を受け取る
使用中のテーマの functions.php にコードを追記して保存
// 自動更新成功時の通知メールを停止する(失敗時は通知されます)
add_filter( 'auto_core_update_send_email', 'custom_stop_auto_update_success_emails', 10, 4 );
function custom_stop_auto_update_success_emails( $send, $type, $core_update, $result ) {
// 更新結果が成功(success)の場合のみメール送信をキャンセル
if ( ! empty( $type ) && $type === 'success' ) {
return false;
}
// 失敗(fail/critical)などの場合は通常通りメールを送信
return $send;
}
