Action hook 'untrashed_post'

in WP Core File wp-includes/post.php at line 4103

View Source

untrashed_post

Action Hook
Description
Fires after a post is restored from the Trash.

Hook Information

File Location wp-includes/post.php View on GitHub
Hook Type Action
Line Number 4103

Hook Parameters

Type Name Description
int $post_id Post ID.
string $previous_status The status of the post at the point where it was trashed.

Usage Examples

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

function my_custom_function($post_id, $previous_status) {
    // Your custom code here
}

Source Code Context

wp-includes/post.php:4103 - How this hook is used in WordPress core
<?php
4098  	 * @since 5.6.0 Added the `$previous_status` parameter.
4099  	 *
4100  	 * @param int    $post_id         Post ID.
4101  	 * @param string $previous_status The status of the post at the point where it was trashed.
4102  	 */
4103  	do_action( 'untrashed_post', $post_id, $previous_status );
4104  
4105  	return $post;
4106  }
4107  
4108  /**

PHP Documentation

<?php
/**
	 * Fires after a post is restored from the Trash.
	 *
	 * @since 2.9.0
	 * @since 5.6.0 Added the `$previous_status` parameter.
	 *
	 * @param int    $post_id         Post ID.
	 * @param string $previous_status The status of the post at the point where it was trashed.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.