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) ?

Answer

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() in admin_notices hook to display (will need to hook for non-settings screens).

Tagged with →  
Share →

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>