[wp-hackers] applying a filter to when a new post is made

Ryan Boren ryan at boren.nu
Mon Aug 9 23:03:31 UTC 2004


On Mon, 2004-08-09 at 23:13 +0100, Giacomo Lacava wrote:
> Chuck Guenther wrote:
> 
> > add_action('publish_post', 'functionName', 0);
> > add_action('edit_post', 'functionName', 0);
> 
> I'll jump on this thread to ask for some clarifications...
> 
> When does WP actually call these two interfaces, "publish_post" and 
> "edit_post"? is it _before_ publishing/editing (that is, committing 
> changes to db) or _after_ the fact?

They're done after the changes are committed to the DB.  However, a post
ID is passed along which you can use to manipulate the post in the DB.
Use wp_get_single_post() and wp_update_post() to make things easier.
You can use them in 1.3, at least.  I'm not sure if 1.2 has those.

Ryan

> I ask because I'm writing a simple version control plugin right now :) 
> If it's like I hope, these hooks are invoked before actually committing 
> the new data to the db, and my plugin is almost done ;) otherwise I'm 
> back to the drawing board.
> 
> Giacomo
> (who's becoming strangely addicted to WP plugin scripting)
> _______________________________________________
> hackers mailing list
> hackers at wordpress.org
> http://wordpress.org/mailman/listinfo/hackers_wordpress.org




More information about the hackers mailing list