Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to collect main info about post like Title etc. in moment when post was written and it's going to be published and perform some actions on this data. What's the hook for that?

Thanks!

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

The function is wp_insert_post(), and as you can see there are some hooks you can use to modify data. wp_insert_post_data is a filter that gets all data right before it will be inserted into the database, so you modify it there and don't need to do anything to get it saved. At the end of the function you can see the save_post action and its equivalent wp_insert_post, which are more appropriate if you want to do something (instead of change something).

These functions are fired when a post is saved, not only when it is published. For the publish action, look at wp_transition_post_status(), which has three hooks:

  • transition_post_status, called with the new and old statuses, and the post data
  • {$old_status}_to_{$new_status}, like draft_to_publish, called with the post data
  • {$new_status}_{$post->post_type}, like publish_page, called with the post ID and post data
share|improve this answer
    
Thanks a lot!!! –  Paul Nov 15 '10 at 19:29
add comment

Also check here: WordPress prompt checklist before publish? "WordPress prompt checklist before publish?"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.