Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#48769 new enhancement

meta_input, tax_input, tags_input and post_category arguments are not available in functions or methods hooked to wp_insert_post

Reported by: henrywright's profile henry.wright Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch dev-feedback
Focuses: Cc:


Functions and methods hooked to wp_insert_post are currently passed $post_ID, $post and $update. When a call to wp_insert_post() is made we can pass an array argument. The array can have meta_input, tax_input, tags_input and post_category elements.

Current call to do_action():

do_action( 'wp_insert_post', $post_ID, $post, $update );


do_action( 'wp_insert_post', $post_ID, $post, $update, $postarr );


$postarr could be either the raw array passed to wp_insert_post() or the result of the raw array being merged with the set of defaults used.

There are more hooks in the wp_insert_post() function such as save_post. These could be updated in the same way for consistency.

Attachments (1)

48769.diff (965 bytes) - added by henry.wright 4 years ago.

Download all attachments as: .zip

Change History (5)

#1 @henry.wright
4 years ago

This may not be feasible because I notice the wp_insert_post hook is used elsewhere and $postarr doesn't seem to be available in that context

#2 @henry.wright
4 years ago

  • Keywords dev-feedback added

In order to make the argument data available we may need to add a new hook. Looking at the wp_insert_post() function definition I'm struggling to find a suitable existing hook

4 years ago

#3 @henry.wright
4 years ago

  • Keywords has-patch added

48769.diff introduces a new hook post_inserted in wp_insert_post().

post_inserted is very much like post_updated but it will run when a post is created only. post_inserted will give hooked functions access to the $postarr array. The existing post_updated hook has been extended so that $postarr is available to hooked functions.

#4 @henry.wright
4 years ago

  • Component changed from General to Posts, Post Types
Note: See TracTickets for help on using tickets.