WordPress.org

Ready to get started?Download WordPress

Codex

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

Function Reference/get settings errors

Description

Fetch settings errors registered by add_settings_error().

Checks the $wp_settings_errors array for any errors declared during the current pageload and returns them.

If changes were just submitted ($_GET['settings-updated']) and settings errors were saved to the 'settings_errors' transient then those errors will be returned instead. This is used to pass errors back across pageloads.

Use the $sanitize argument to manually re-sanitize the option before returning errors. This is useful if you have errors or notices you want to show even when the user hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook)

Usage

<?php get_settings_errors$setting$sanitize ?>

Parameters

$setting
(string) (optional) Optional slug title of a specific setting whose errors you want.
Default: None
$sanitize
(boolean) (optional) Whether to re-sanitize the setting value before returning errors.
Default: false

Return Values

(array) 
Array of settings errors.
array(
    'setting' =>  $setting,
    'code'    =>  $code,
    'message' =>  $message,
    'type'    =>  $type
);

Examples

Notes

Change Log

Since: 3.0

Source File

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

Related

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.