Support » Plugins » Adding error messages to post.php (looking as WP default ones)

  • Resolved aurimas



    I am currently working on developing custom post types in WP 3.0 (custom meta boxes, custom fields, etc). In some cases on a save_post hook I am doing some back-end verification (like, to see if an uploaded image fits the required dimensions or a custom caption length does not exceed XX characters).
    In case the verification fails, I would like to display users notifications (around the place where the “Post updated” message appears). However I can’t find anything about how that could be done. I definitely know that some plugins throw such notifications on their own pages, but browsing through their code did not help.

    Any guidance would be appreciated 😉

Viewing 1 replies (of 1 total)
  • And, of course, a bit of more google search, and I arrived at the asnwer:

    one needs to use the admin_notices hook:

    add_action('admin_notices', create_function('', 'echo "<div class=\"error\">This is my error";')); //for errors (red background)
    add_action('admin_notices', create_function('', 'echo "<div class=\"updated\">This is my error";')); //for other notifications (yellow background)
Viewing 1 replies (of 1 total)
  • The topic ‘Adding error messages to post.php (looking as WP default ones)’ is closed to new replies.