wp_untrash_post_status WordPress Filter Hook

The wp_untrash_post_status hook is called when a post is restored from the trash. This hook can be used to perform an action when a post is restored from the trash. For example, you could use this hook to send an email notification or log the event.

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

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.


Top ↑

Parameters

$new_status

(string)The new status of the post being restored.

$post_id

(int)The ID of the post being restored.

$previous_status

(string)The status of the post at the point where it was trashed.


Top ↑

Source

File: wp-includes/post.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More