[wp-hackers] How to use post_updated_messages filter

Anca Mosoiu anca at anca.tv
Thu Aug 26 00:16:22 UTC 2010


Hello,

I'm developing a plugin that supports additional actions on the post.php page (besides publish, trash, update, etc).

I figured out how to hook my function to the save_post action, and now I'm trying to provide a user message.  I noticed that there is a "post_updated_messages" filter that allows you to define additional user-facing messages.  There is a nice example of using this as part of creating a custom content type:  http://codex.wordpress.org/Function_Reference/register_post_type.

I also looked at the edit-form-advanced.php, where messages are defined and where the post_updated_messages filter is called.  

My question is...  What's the recommended way to use this filter?  Do I...

(a) Add more messages (with new indexes) to the $messages array and set my $message to the new index I've defined? (How?)

or

(b) Replace the "Post Updated" message (index 4) with my status report based on whether my action was triggered (and successful)?

or

(c) something else?

Right now I'm leaning towards (b), just because it seems that messages map to particular statuses and I know which one to change, but it doesn't feel like as clean a solution as (a).

Thanks,

Anca.
=+=+=+=+=+=+
Anca Mosoiu
anca at anca.tv



More information about the wp-hackers mailing list