Wordpress: Permanently deleting custom post type post. remove the: "1 post moved to the Trash. Undo" message

Asta :

Sorry if there is already an answer to this but I couldn't find it.

So I have this script that permanently deletes a post from a custom post type. It does permanently delete the post. but after it's deleted I get this message:

enter image description here

But I want this message gone because even if u the press undo button it just says: enter image description here

the code for deleting the posts is:

function members_skip_trash($post_id) {
    if (get_post_type($post_id) == 'members') { 
        // Force delete
        wp_delete_post( $post_id, true );
    }
}
add_action('trashed_post', 'members_skip_trash');

So how do I get the 1 post moved to the trash message?

thingEvery :

A quick and dirty way to do it would be to find this file:

/wp-admin/edit.php

And comment out the following line:

echo '<div id="message" class="updated notice is-dismissible"><p>' . join( ' ', $messages ) . '</p></div>';

Of course that will get rid of all your 'moved to Trash' messages. So you'll probably want to keep it in there, but check for your custom post type first.

Or better yet, figure out how to override this from your functions.php file so the next WP update doesn't kill it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=15511&siteId=1