function add_settings_error( $setting, $code, $message, $type = 'error' ) {}

Register a settings error to be displayed to the user
Part of the Settings API. Use this to show messages to users about settings validation problems, missing settings or anything else.


  • string $setting: Slug title of the setting to which this error applies
  • string $code: Slug-name to identify the error. Used as part of ‘id’ attribute in HTML output.
  • string $message: The formatted message text to display to the user (will be shown inside styled <div> and <p>)
  • string $type: The type of message it is, controls HTML class. Use ‘error’ or ‘updated’.

Source code

function add_settings_error( $setting, $code, $message, $type = 'error' ) {

	global $wp_settings_errors;

	if ( !isset($wp_settings_errors) )

		$wp_settings_errors = array();

	$new_error = array(

		'setting' => $setting,

		'code' => $code,

		'message' => $message,

		'type' => $type


	$wp_settings_errors[] = $new_error;



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: