wppaste
WordPress

apply_filters( 'wp_untrash_post_status', string $new_status, int $post_id, string $previous_status )

Since
5.6.0
Filters the status that a post gets assigned when it is restored from the trash (untrashed).

Description

By default posts that are restored will be assigned a status of 'draft'. Return the value of $previous_status in order to assign the status that the post had before it was trashed. The wp_untrash_post_set_previous_status() function is available for this.

Prior to WordPress 5.6.0, restored posts were always assigned their original status.

Compatibility

WordPress
since 5.6.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$new_statusstring
The new status of the post being restored.
$post_idint
The ID of the post being restored.
$previous_statusstring
The status of the post at the point where it was trashed.

Where this hook fires · 1

  • wp-includes/post.php:4076wp_untrash_post()

Source code

	 * @since 5.6.0	 *	 * @param string $new_status      The new status of the post being restored.	 * @param int    $post_id         The ID of the post being restored.	 * @param string $previous_status The status of the post at the point where it was trashed.	 */	$post_status = apply_filters( 'wp_untrash_post_status', $new_status, $post_id, $previous_status ); 	delete_post_meta( $post_id, '_wp_trash_meta_status' );	delete_post_meta( $post_id, '_wp_trash_meta_time' ); 	$post_updated = wp_update_post(		array(

Changelog

Introduced in 5.6.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.