I’m using the trash_post
hook to set a flag in a custom table to indicate that this item is “deleted”, but when the user chooses to restore that post, what hook can I use for that? I couldn’t find anything on this page https://codex.wordpress.org/Plugin_API/Action_Reference, but maybe there’s another way to solve the problem.
Thanks!
Looking at the code for WP 3.3.2, it seems that
trash_post
is actuallywp_trash_post
. From thewp_trash_post()
function in/wp-includes/post.php
:So … I’d double check the hook you’re using to set your initial flag.
However, there is a hook you can use to detect when a user restores a post. It’s aptly named
untrash_post
.Here it is in action from the same core file:
When a post is untrashed, WordPress calls
wp_untrash_post
. That calls two actions:untrash_post
prior to untrashing anduntrashed_post
after. Both pass the post ID as an argument.Somewhere on the edit.php is a
wp_untrash_post
but the documentation page is empty (http://codex.wordpress.org/Function_Reference/wp_untrash_post), maybe if you take a look to the source you may be able to find a wayhttp://wpseek.com/wp_untrash_post/
http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-admin/edit.php.source.html