Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/settings errors


Display settings errors registered by add_settings_error().

Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().

This is called automatically after a settings page based on the Settings API is submitted. Errors should be added during the validation callback function for a setting defined in register_setting().

The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization on its current value.

The $hide_on_update option will cause errors to only show when the settings page is first loaded.

If the user has already saved new values it will be hidden to avoid repeating messages already shown in the default error reporting after submission. This is useful to show general errors like missing settings when the user arrives at the settings page.


<?php settings_errors$setting$sanitize$hide_on_update ?>


(string) (optional) Optional slug title of a specific setting who's errors you want.
Default: None
(boolean) (optional) Whether to re-sanitize the setting value before returning errors.
Default: false
(boolean) (optional) If set to true errors will not be shown if the settings page has already been submitted.
Default: false

Return Values

This function does not return a value.


 * Displays all messages registered to 'your-settings-error-slug'
function your_admin_notices_action() {
    settings_errors( 'your-settings-error-slug' );
add_action( 'admin_notices', 'your_admin_notices_action' );


Change Log

Since: 3.0

Source File

settings_errors() is located in wp-admin/includes/template.php.


Settings API: register_setting(), unregister_setting(), add_settings_field(), add_settings_section(), add_settings_error(), get_settings_errors(), settings_errors()

See also index of Function Reference and index of Template Tags.