[wp-hackers] applying a filter to when a new post is made
Scott Reilly
coffee2code at scottreilly.net
Mon Aug 9 23:47:42 UTC 2004
Oops... Ryan beat me to it.
On Monday 09 August 2004 07:19 pm, Scott Reilly wrote:
> From what I gather in the code, 'publish_post' and 'edit_post' are
> triggered at the end of those respective events. The post has by then been
> published/edited and stored into the database.
>
> Those particular events are handled differently than the usual filter usage
> (i.e. add_filter('the_content', myFunction); ) where your function is
> defined as: function myFunction ($text)
>
> When hooking these two actions, your function will be sent the postID, not
> its content. Therefore, if you want to manipulate the post when it gets
> published/edited, your plugin will have to accept the postID (i.e. function
> myFunction ($post_ID)) and use it to retrieve the post from the database,
> and then store it back into the database when you're done.
>
> Then again, I haven't tried it myself... yet.
>
> -Scott
> http://www.coffee2code.com
More information about the hackers
mailing list