Fires once a post has been saved.
Description
The dynamic portion of the hook name, $post->post_type, refers to the post type slug.
Possible hook names include:
save_post_postsave_post_page
Parameters
$post_idint- Post ID.
$postWP_Post- Post object.
$updatebool- Whether this is an existing post being updated.
Source
do_action( "save_post_{$post->post_type}", $post_id, $post, $update );
Changelog
| Version | Description |
|---|---|
| 3.7.0 | Introduced. |
The hook also fires when clicking on the “Add New” option for the custom post type, as it creates the draft in the DB, and when calling the
wp_update_postfunction as well.It’s also good to note that this hook is also called when trashing a post or restoring it from trash.
It’s kind of sad that this more explicit action fires before the less explicit ‘save_post’ action.
This means if a 3rd party plugin does something using ‘save_post’ you need to use ‘save_post’ to override it too.
Notify your newsletter subscribers when a new book (custom post) is added-