Been playing around with the Settings API and found that messages (for success or errors) are only displayed when a settings page is hooked into WordPress menu via add_options_page(). Anything else will not work e.g. add_dashboard_page(). Would like to know if this is true? Sample code I tried with is the answer containing the "RegisteredSettingsTest" class at Where to hook register_settings for Settings API when also want to update options outside of Settings API?
|
Thanks Chip (excellent Settings API tutorial) and t31os (great snippet of code for quick testing) for both your suggestions. I did some further digging and found that the default messages can indeed be displayed if I hook into any menu but only if the function settings_errors() is called. For example, modifying t31os code as follows:
Custom error messages can also be added by calling the add_settings_error() function for displaying success or failure message by specifying the |
||||
|
|
I use Settings API integration with my Theme,use I suspect that it is a problem with your code rather than a Settings API limitation. Can you post your actual code, so we can help you resolve any code-related issues? EDIT You may need to output your admin notices explicitly. For example, here is what I use in my settings page markup function:
I assume you could do something similar for error notices, as well. |
|||||||||
|