首页 WordPress函数大全 add_settings_error()

add_settings_error()

2020-05-01 / 2695阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

add_settings_error( string $setting, string $code, string $message, string $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.

Settings errors should be added inside the $sanitize_callback function defined in register_setting() for a given setting to give feedback about the submission.

By default messages will show immediately after the submission that generated the error. Additional calls to settings_errors() can be used to show errors even when the settings page is first accessed.

参数

$setting

(string)
(Required)
Slug title of the setting to which this error applies.

$code

(string)
(Required)
Slug-name to identify the error. Used as part of 'id' attribute in HTML output.

$message

(string)
(Required)
The formatted message text to display to the user (will be shown inside styled div and p tags).

$type

(string)
(Optional)
Message type, controls HTML class. Possible values include 'error', 'success', 'warning', 'info'.

Default value: 'error'

大家谈论
    我的见解