Action hook 'wp_insert_post'

in WP Core File wp-includes/class-wp-customize-manager.php at line 3121

View Source

wp_insert_post

Action Hook
Description
Trashes or deletes a changeset post. The following re-formulates the logic from `wp_trash_post()` as done in `wp_publish_post()`. The reason for bypassing `wp_trash_post()` is that it will mutate the the `post_content` and the `post_name` when they should be untouched.

Hook Information

File Location wp-includes/class-wp-customize-manager.php View on GitHub
Hook Type Action
Line Number 3121

Hook Parameters

Type Name Description
int|WP_Post $post The changeset post.

Usage Examples

Basic Usage
<?php
// Hook into wp_insert_post
add_action('wp_insert_post', 'my_custom_function', 10, 1);

function my_custom_function($post) {
    // Your custom code here
}

Source Code Context

wp-includes/class-wp-customize-manager.php:3121 - How this hook is used in WordPress core
<?php
3116  
3117  		/** This action is documented in wp-includes/post.php */
3118  		do_action( 'save_post', $post->ID, $post, true );
3119  
3120  		/** This action is documented in wp-includes/post.php */
3121  		do_action( 'wp_insert_post', $post->ID, $post, true );
3122  
3123  		wp_after_insert_post( get_post( $post_id ), true, $post );
3124  
3125  		wp_trash_post_comments( $post_id );
3126  

PHP Documentation

<?php
/**
	 * Trashes or deletes a changeset post.
	 *
	 * The following re-formulates the logic from `wp_trash_post()` as done in
	 * `wp_publish_post()`. The reason for bypassing `wp_trash_post()` is that it
	 * will mutate the the `post_content` and the `post_name` when they should be
	 * untouched.
	 *
	 * @since 4.9.0
	 *
	 * @see wp_trash_post()
	 * @global wpdb $wpdb WordPress database abstraction object.
	 *
	 * @param int|WP_Post $post The changeset post.
	 * @return mixed A WP_Post object for the trashed post or an empty value on failure.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 1
  • File: wp-includes/class-wp-customize-manager.php
Related Hooks

Related hooks will be displayed here in future updates.