pass error to admin_notices on “quick edit”/save_post action

I currently have add_action('admin_notices','my_notice_function'); updating correctly whenever a page is refreshed (it’s checking if a certain page has a certain parent) but when using the “Quick Edit” my admin_notices is not fired.

When trying to hook the same function into add_action('save_post','my_notice_function')); it breaks the formatted table and doesn’t display the error message in the normal admin_notices section at the top of the page.

Read More

Any help would be greatly appreciated.

Code, as it stands:

public function init() {
  add_action('admin_notices','page_check');
  add_action('save_post','page_check');
}

public function page_check(){

  if(PluginCommon::verifyPages('error')){
    ?>
    <div class='alert-message alert-danger' id='page_errors'>
      <h2>A problem has been detected.</h2>
      <ul><?php echo PluginCommon::verifyPages('error'); ?></ul>
    </div>
    <?php 
  }
}

Related posts

Leave a Reply

1 comment

  1. The admin_notices hook fires only once per page load, and isn’t fired when a post is quick-edited.

    You would have to do it browser-side with javascript – that is, listen for when someone edits and saves a post (which is done via AJAX) and use javascript to display a message.

    A quick glance at the javascript file responsible for quick editing (wp-admin/js/inline-edit-post.dev.js), and unfortunately there doesn’t appear to be a way of knowing when the AJAX response has been received.