WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#26862 closed defect (bug) (invalid)

WordPress fires wp_insert_action on every single save and not just when the post is created

Reported by: chriscarvache Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords:
Focuses: Cc:

Description

According to the WP Codex wp_insert_post as an action should fire ONLY when a new post is created. However it seems as if it fires on EVERY save.

See the following stack exchange article:

http://wordpress.stackexchange.com/questions/129734/woocommerce-wp-insert-post-action-firing-on-every-save/129769#129769

Change History (1)

#1 @dd32
7 years ago

  • Component changed from Build Tools to Administration
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version 3.8 deleted

wp_insert_post will be fired on every time a post object is added to the DB, be this from a audit / logging plugin, or from the saving process of WordPress.
Autosaves and revisions will also insert posts, which is probably what you're seeing here.

Some documentation to check out:
http://codex.wordpress.org/Plugin_API/Action_Reference/wp_insert_post
http://codex.wordpress.org/Plugin_API/Action_Reference/save_post (especially the examples)

If that still doesn't help you, please try the Support Forums for support: http://wordpress.org/support/

Note: See TracTickets for help on using tickets.