In my admin panel, if I use a sanitizing callback register_setting()
and the field does not pass through my custom validation, I’ve been preventing the database from updating by using return FALSE;
and adding an error with add_settings_error()
.
How do I return the invalid values back to the form fields that the user submitted, so that they don’t have to start all over again?
This a really good question – my suggestion is to use transients. For instance, in your validation callback:
Then on your settings page, if the options have been validated – check for the transient, and use the ‘failed’ settings, if they are found: