Две ключевые функции: settings_errors() и add_settings_error()

Рабочий пример:


function myplugin_admin_messages() {
if(isset($_GET['myplugin-message']) && $_GET['myplugin-message'] == ‘discount_updated’) {
add_settings_error( ‘myplugin-notices’, ‘myplugin-discount-updated’, __(‘Discount code updated.’, ‘myplugin’), ‘updated’ );
}
if(isset($_GET['myplugin-message']) && $_GET['myplugin-message'] == ‘discount_update_failed’) {
add_settings_error( ‘myplugin-notices’, ‘myplugin-discount-updated-fail’, __(‘There was a problem updating your discount code, please try again.’, ‘myplugin’), ‘error’ );
}
settings_errors( ‘myplugin-notices’ );
}
add_action(‘admin_notices’, ‘myplugin_admin_messages’);