Hi
Deleting a post with a custom post_type using MB frontend submission form permanently deletes the post. Even when force_delete = "false".
I see that the MBFS\Form class calls the following method when deleting posts by ID.
public function delete() {
if ( empty( $this->config['post_id'] ) ) {
return;
}
$force_delete = 'true' === $this->config['force_delete'];
do_action( 'rwmb_frontend_before_delete', $this->config );
wp_delete_post( $this->config['post_id'], $force_delete );
do_action( 'rwmb_frontend_after_delete', $this->config, $this->config['post_id'] );
}
So the wp_delete_post() function is always called.
Inside the wp_delete_post() function WordPress only reverts to wp_trash_post() when post_type == 'post' or post_type == 'page'.
if ( ! $force_delete && ( 'post' === $post->post_type || 'page' === $post->post_type ) && 'trash' !== get_post_status( $postid ) && EMPTY_TRASH_DAYS ) {
return wp_trash_post( $postid );
}
I understand that I could add an action to "rwmb_frontend_before_delete" hook and trash the post myself. But that would mean extra code and overhead.
Would it be possible to avoid calling wp_delete_post() for custom post_types? Maybe by calling wp_trash_post() instead of wp_delete_post() when for_delete="false"?
Cheers and thanks in advance.
Tako