WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Success
    Member
    Posted 8 years ago #

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

  2. angsuman
    Member
    Posted 8 years ago #

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

  3. basketball
    Member
    Posted 8 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
    Member
    Posted 8 years ago #

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

  5. This should do it I think:

    <?php

    get_currentuserinfo();
    $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

Tags