How to add a Delete link to each blog post? (5 posts)

  1. Success
    Posted 10 years ago #

    On our blog pages, how to add a Delete link to the line "Edit | Permalink | Comments »" ?

  2. angsuman
    Posted 10 years ago #

    You want your members to be able to delete post or everyone?

  3. basketball
    Posted 10 years ago #

    I think he means just the admin being allowed to delete the post (similar to the edit link).

    I also want to figure out how to do this, any ideas?

  4. Success
    Posted 10 years ago #

    I want admin to delete. Yes, the person above me is right.

  5. Alex Mills (Viper007Bond)
    Posted 10 years ago #

    This should do it I think:


    $postauthordetails = get_userdata($post->post_author);

    if ($userdata->user_level >= $postauthordetails->user_level) {
    echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/post.php?action=delete&amp;post=' . $post->ID . "\" onclick=\"return confirm('You are about to delete this post [bs]'" . $post->post_title . "[bs]'[bs]n [bs]'OK[bs]' to delete, [bs]'Cancel[bs]' to stop.')\">Delete</a>";


    [edit] Replace [bs] with a backslash. This stupid forum software keeps stripping them if I add them in. :| [/edit]

    Use it within The Loop and it should only show up on posts made by someone of the same or lesser userlevel than the level of the current user.

Topic Closed

This topic has been closed to new replies.

About this Topic