Title sounds counter-intuitive but bear with me. :)
I have options page, made with Settings API. When user enters invalid data I want to display error notice with
But! To determine that data is invalid I need to make an remote API call. That call relies on saved data. So I can't do this in sanitization callback (which is recommended place to throw such notices) because my data is not saved yet.
Instead I had tried to hooking my check into
admin_notices. It works fine most of the time except one (and most important) case - when settings are saved they are always followed by native Settings saved. notice and my custom notices are completely ignored for some reason.
So how do I throw that error notice even if WP thinks everything is fine?
More focused question - why exactly Settings saved. trumps any other notices?
PS I could try to make API call optionally take data as argument instead of reading it from saved option, but so far I think it will make arguments overly bulky.