int $post_id, WP_Post $post, bool $update )
Fires once a post has been saved.
Whether this is an existing post being updated.
wp_insert_post action fires once a post has been saved. You have the ability to set it to only fire on new posts or on all save actions using the parameters. Please see Plugin_API/Action_Reference/save_post for more information. Keep in mind that this action is called both for actions in the admin as well as anytime the wp_insert_post() function is invoked.
This action can be replicated by creating a conditional in a save_post action that excludes certain post statuses.
An important distinction of
wp_insert_post action is that it is fired after
update_post_meta has been called.
View all references
do_action( 'wp_insert_post', $post_id, $post, $update );
Below is a basic example that will send an email every time a post or page is created or updated on your website. (copied from codex)
It’s not reliable to check first publication.
truein first time post is published if you are using dashboard because it creates revisions.