Fix permission error for deleting custom post from front-end?

Here you go, this creates a Delete Post link that only appears to the user if they are both logged in and the author of the post. When the link is clicked, they get a js confirmation asking them if they’re sure, which once clicked will delete the post. And it does work with Custom Post Types, tested it myself.

<?php if ($post->post_author == $current_user->ID) { ?><p><a onclick="return confirm('Are you SURE you want to delete this post?')" href="https://wordpress.stackexchange.com/questions/33046/<?php echo get_delete_post_link( $post->ID ) ?>">Delete post</a></p><?php } ?>