save_post_<post_type>

Fires once a post has been saved.

Description

do_action( 'save_post_<post_type>', (int) $post_id, (WP_Post) $post, (bool) $update ); 

The dynamic portion(s) of the hook name refer to the post type slug.

Parameters (3)

0. $post_id (int)
The post id.
1. $post (WP_Post)
Post object.
2. $update (bool)
Whether this is an existing post being updated or not.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'save_post_{$post_type}', $post_id, $post, $update ); 
The following example is for adding a hook callback.
  1. // define the save_post_<post_type> callback 
  2. function action_save_post_post_type( $post_id, $post, $update ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( "save_post_{$post_type}", 'action_save_post_post_type', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( "save_post_{$post_type}", 'action_save_post_post_type', 10, 3 ); 

Defined (3)

The action is defined in the following location(s).

/wp-includes/post.php  
  1. do_action( "save_post_{$post->post_type}", $post_ID, $post, $update ); 
  1. do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); 
/wp-includes/theme.php  
  1. do_action( "save_post_{$post->post_type}", $post->ID, $post, true );