There are several components to error/notice creation and display process:
add_settings_error() call to add item to stack (global
settings_errors transient that keeps the errors so they survive move from page to page.
get_settings_errors() to retrieve errors from memory or transient and then displays them.
These work like a charm for Settings API, but unfortunately they aren't setup for generic use. On other hand it is trivial to work around that.
admin_notices on your plugin's page, pass the error code to it so it only shows your stuff.
Manually save errors to
settings_errors transient (just stuff that global variable into it).
get_settings_errors() expects hint in GET parameters (
$_GET['settings-updated']) that it should check transient instead of memory you can either provide that or get errors from transient yourself and save them back to global variable before your
You are turning this into bit of a mess with multiple question, so I will try to address your concerns here.
Settings API does work with admin pages, that don't use Settings section as base. Your real issue is that in that case error/notice reporting does not work.
First here is what happens when you post form, set up with Settings API:
- Data gets posted to special
- There data gets sanitized/validated using callback.
- Any error/notices that came up during sanitization/validation are collected and saved in transient.
- You are redirected back to wherever you came from.
Now when you load admin page it checks if this page belongs to Settings section and if that case includes tiny
options-head.php file, that deals with retrieving and displaying errors notices.
So the only thing "not working" on other pages is this latter step, which is trivial to do yourself with overview of related function above (I probably went into too much details on transient, you won't need that for basic case).