I need both Admin and Editor role users to be able to delete a custom post type from the front-end. I found the code to create a post delete link, but whenever either role tries to delete there is an error:
Forbidden You don't have permission to access /wp-admin/post.php on this server.
Any ideas? Is it because this is a custom post type? The post delete code is included below.
In function.php:
function wp_delete_post_link($link = 'Delete This', $before = '', $after = '')
{
global $post;
if ( $post->post_type == 'page' ) {
if ( !current_user_can( 'edit_page', $post->ID ) )
return;
} else {
if ( !current_user_can( 'edit_post', $post->ID ) )
return;
}
$link = "<a onclick=\"return confirm('Are you SURE you want to delete this post/page?')\" href='" . wp_nonce_url( get_bloginfo('url') . "/wp-admin/post.php?action=delete&post=" . $post->ID, 'delete-post_' . $post->ID) . "'>".$link."</a>";
echo $before . $link . $after;
}
Inserted into page:
<?php wp_delete_post_link('Delete', ' <strong class="delete">', '</strong> ') ?>
wp-admin/post.php
?