WordPress action hook · part of WordPress core
wp_after_insert_post
A WordPress core action that 8 plugins also fire themselves, running on 31K+ sites between them.
How to use wp_after_insert_post
It's an action: your callback runs at that point and receives 4 arguments. Nothing needs to be returned.
Add this to your theme's functions.php or a small custom plugin:
add_action( 'wp_after_insert_post', function( $ID, $_published, $arg3, $published ) {
// Your code runs here.
}, 10, 4 );Argument names come from PublishPress Revisions: Duplicate Posts, Submit, Approve and Schedule Content Changes's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
8 plugins that fire wp_after_insert_post
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
PublishPress Revisions: Duplicate Posts, Submit, Approve and Schedule Content Changes10,000+ installs
do_action( 'wp_after_insert_post', $_published->ID, $_published, true, $published )admin/revision-action_rvy.php:1323 -
Royal MCP10,000+ installs
do_action( 'wp_after_insert_post', $post_id, $post, true, $post )includes/MCP/Support/Post_Write_Hooks.php:60 -
404 Solution: Redirection and Page Suggestions10,000+ installs
do_action( 'wp_after_insert_post', (int)$before->ID, $after, true, $before )includes/services/WordPressPostMutationNotifications.php:104 -
MSN Partner Hub900+ installs
do_action( 'wp_after_insert_post', $post->ID, $post, true, null )cron/BackgroundTasks.php:69 -
MEGA AI200+ installs
do_action( 'wp_after_insert_post', $post_id, $post_after, true, $post_before )mega.php:8896 -
Your SEO SquadFewer than 10 installs
do_action( 'wp_after_insert_post', $id, $post, true, $post )your-seo-squad.php:1708 -
CatalogFAQFewer than 10 installs
do_action( 'wp_after_insert_post', $id, $updated, true, $post )src/Core.php:407 -
Quick Variable ProductsFewer than 10 installs
do_action( 'wp_after_insert_post', $product_id, $post, (bool) $update, null )includes/class-qvp-product.php:501
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.