• 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 4 replies - 1 through 4 (of 4 total)
  • Moderator Bet Hannon

    (@bethannon1)

    Are your authors logged in?

    Authors can delete_published_posts, and they should have access to the wp-admin link — IF they are logged in. No one will be able to delete/edit from the front of the site unless they are logged in.

    Thread Starter duffmen

    (@duffmen)

    Yes, they are. All posts are created by authors from frontend with Private status by default. So authors can see only their own posts when they are logged in.

    Moderator Bet Hannon

    (@bethannon1)

    I think will will be more likely to find help in the support forum for that plugin, where the plugin authors & community can offer suggestions:
    https://wordpress.org/plugins/wp-user-frontend/

    Thread Starter duffmen

    (@duffmen)

    I don’t use the wp-user-frontend plugin for create posts from frontend.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Delete Post From front Page ( With Wp-admin restriction )’ is closed to new replies.