Action hook 'wp_creating_autosave'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php at line 416

View Source

wp_creating_autosave

Action Hook
Description
Creates autosave for the specified post. From wp-admin/post.php.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php View on GitHub
Hook Type Action
Line Number 416

Hook Parameters

Type Name Description
array $post_data Associative array containing the post data.
array $meta Associative array containing the post meta data.

Usage Examples

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

function my_custom_function($post_data, $meta) {
    // Your custom code here
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php:416 - How this hook is used in WordPress core
<?php
 411  		if ( $old_autosave ) {
 412  			$new_autosave['ID']          = $old_autosave->ID;
 413  			$new_autosave['post_author'] = $user_id;
 414  
 415  			/** This filter is documented in wp-admin/post.php */
 416  			do_action( 'wp_creating_autosave', $new_autosave );
 417  
 418  			// wp_update_post() expects escaped array.
 419  			$revision_id = wp_update_post( wp_slash( $new_autosave ) );
 420  		} else {
 421  			// Create the new autosave as a special post revision.

PHP Documentation

<?php
/**
	 * Creates autosave for the specified post.
	 *
	 * From wp-admin/post.php.
	 *
	 * @since 5.0.0
	 * @since 6.4.0 The `$meta` parameter was added.
	 *
	 * @param array $post_data Associative array containing the post data.
	 * @param array $meta      Associative array containing the post meta data.
	 * @return mixed The autosave revision ID or WP_Error.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php
Related Hooks

Related hooks will be displayed here in future updates.