Update badgeos_achievement_type_changed() to ensure DOING_AUTOSAVE constant is defined before checking state.