Hook onto trashed_post
and use wp_untrash_post()
to reverse upon meeting a condition, pseudocode example…
add_action('trashed_post', 'wpse_218031_trashed_post');
function wpse_218031_trashed_post($post_id){
//use post_id to check conditions... if not met call:
if ( $some_condition ) {
wp_untrash_post($post_id);
}
}
trashed_post
runs after wp_trash_post
and after the post is moved to trash.
By the way, if the constant EMPTY_TRASH_DAYS
is defined and is false
posts will be permanently deleted and the subsequent hooks mentioned will not be fired, in which case wp_delete_post()
will be called instead.