[wp-hackers] register_settings and admin_notices

Ade Walker photofantaisie at gmail.com
Fri Oct 23 09:37:15 UTC 2009


Hi,

Possibly more a support question, but I think the answer may be useful to
other hackers...

I'm re-writing some of my plugins to implement register_settings() for the
plugin's settings page, ie replacing the "old" $POST and nonces way. This
works fine, including the register_settings() callback function which I've
defined for sanitising and validating the user input.

However, I can't find a way to display a customised "updated" message to
display validation errors found when the callback function is run. For
example, the settings page has a reset option to revert all settings to
their defaults and, if this is set, I want to display an alternative to the
standard "Settings Saved" message, eg "All settings have been reset", or
something along those lines.

The problem I have is getting the various messages to display. Any pointers
for how I can do this? Is it a question of hooking into admin_notices, and
if so when (my attempt at doing this within the callback function haven't
worked), or is there a different approach I should be taking? Or am I
missing something blindingly obvious here?

Any pointers would be really useful.

Thanks!

Ade.


More information about the wp-hackers mailing list