Show warning/error to user without using wp_die

I’m currently developing a WordPress plugin. For my plugin to work I need some info te be filled in on the settings page.

  1. Is there a way to warn/throw an error so the blog admin can see this message on his/her dashboard?
  2. Is there another function to show errors other than wp_die()? Just in case my plugin (or someone else) screws up and I want to notify that in a nicely fashion. 😉

Related posts

Leave a Reply

1 comment

  1. I would recommend using the admin_notices action. This lets you display warnings and errors and direct your users to a page:

    add_action('admin_notices','my_custom_warning');
    function my_custom_warning() {
      if( true == true ) {
        echo '<div id="my-custom-warning" class="error fade"><p>This is a test</p></div>';
      }
    }
    

    This method makes sure your users can still use WordPress but will let them know where they can get information on and fix a potential problem.