Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

duffmen on "Delete Post From front Page ( With Wp-admin restriction )"

$
0
0

Hi there.
Could someone help to solve problem:
I need that my authors to be able to delete their own posts from frontend.
I use the function to do this:

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;
  }
    $message = "Are you sure you want to delete ".get_the_title($post->ID)." ?";
    $delLink = wp_nonce_url( get_bloginfo('url') . "/wp-admin/post.php?action=delete&post=" . $post->ID, 'delete-post_' . $post->ID);
    $htmllink = "<a href='" . $delLink . "' />".$link."";
    echo $before . $htmllink . $after;
}

But also I use "admin_bar_disabler" plugin which restricts all roles to access to the admin bar (except "Administartor").
So authors can't delete any own posts because they don't have access to /wp-admin link.
Administrator can delete any post from frontend using the function wp_delete_post_link.
Thanks for advance.


Viewing all articles
Browse latest Browse all 8245

Trending Articles