I have set up a custom post type, which user can edit from the frontend. I'm using
wp_delete_post() to allow users to delete a post they created. It works, but the posts get deleted instead of being moved to trash.
I have tried moving a post to the bin via the backend and it works like you would expect it, the post is moved to the Bin. So I'm not sure why the
wp_delete_post doesn't work the same way, but permanently removes the post instead.
According to the WordPress Codex, the second parameter of the
wp_delete_post() function is a boolean, which, if set to false, should move the post to trash, not permanently delete it. The second parameter is set to false by default, so this is my code:
wp_delete_post( $race->ID );
I'm aware that I can use the
wp_trash_post() function instead (which is actually what I'm using now, since the
wp_delete_post, doesn't do what I want it to do), but I would like to find out why the
wp_delete_post() function doesn't work correctly.