I have a simple meta box that updates the post custom fields (using update_post_meta()
).
How can I send a error or warning message to the next page after the user publishes/updates the post and doesn’t fill one of the meta box fields (or fills them with invalid data) ?
You can do this by hand, but WP natively does it like this for settings errors:
-
add_settings_error()
to create message. - Then
set_transient('settings_errors', get_settings_errors(), 30);
-
settings_errors()
inadmin_notices
hook to display (will need to hook for non-settings screens).