Perform an action when post is updated/published

The save_post action fires When a post is updated and/or published — including when a new post is inserted.

<?php
add_action( 'save_post', 'wpse41912_save_post' );
function wpse41912_save_post()
{
    // do stuff
}

If you want your functions to fire only when a post is being edited, you can hook into edit_post.

If you want it to fire when a post is moved from draft to publish you can hook into transition_post_status.

Leave a Comment