WordPress.org

Ready to get started?Download WordPress

Forums

How to Display a Message Box in post.php After save_post Action is Executed? (3 posts)

  1. microberto
    Member
    Posted 2 years ago #

    Hi all,

    I'm developing my first plugin - It uses add_action('add_meta_boxes',..) to add some new stuff to the edit post.php screen. I have another action to accomplish a task using add_action('save_post',...)

    Everything executes fine, but sometimes I want to display an error or a general user message to the user. I am not sure where, when, or how to do this.

    I've tried looking at admin_notices and the WP_Error class, but nothing is displaying. I know things are getting executed because my meta boxes show up fine and error_log() functions work from within the save_post action.

    Can anyone help me show a bit of extra information to the user after they've saved their post? I know plugins like sexybookmarks can easily add a red bar to do this, but I can't get the code to display!

    Thanks!

  2. microberto
    Member
    Posted 2 years ago #

    OK, I'm still struggling here, but I've found a few things that might help:

    add_filter('post_updated_messages', 'function_name');

    Well, that doesn't even run.

    Next idea is to steal code from this:
    http://wordpress.org/extend/plugins/wp-update-message/

    Basically, make ANOTHER metabox to display a message. Seriously? This cannot be the only way to display a message to the user....

    Perhaps this?
    http://stackoverflow.com/questions/6152315/wordpress-how-displaying-custom-error-message-in-wp-insert-post-data

    Anyone else? Otherwise I'll get working on this, but it's a bit ridiculous. I just want to pop a box up AFTER save_post.

    Thanks...

  3. microberto
    Member
    Posted 2 years ago #

    Perhaps this?
    http://stackoverflow.com/questions/6152315/wordpress-how-displaying-custom-error-message-in-wp-insert-post-data

    OK, so looking at this solution and doing some error logging, it turns out that the wp_insert_post_data filter happens BEFORE the add_action('save_post',...) stuff gets done. This means that the solution I really want is technically impossible.

    I'm not sure why the message would get displayed before anything really gets done - is that a bug in that it's out of order? You should want everything to get done before messages get printed!

    My next idea is to just put the plugin code INTO the redirect_post_location filter. Sloppy but it could work.

Topic Closed

This topic has been closed to new replies.

About this Topic