[resolved] Deleting a post from front end (6 posts)

  1. valuser
    Posted 5 years ago #

    In a network (multisite) set-up using p2 --- how to include a option for a logged in user to delete a post from their own blog from the front end ??? I haven't the remotest idea how to do this - but some of you might. Any ideas really welcome!!

  2. valuser
    Posted 5 years ago #

    Gone part of the way with help from a forum post at

    Entering <?php if (current_user_can('edit_post', $post->ID)) echo "<a href='" . wp_nonce_url("/wp-admin/post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "'>Delete post</a>" ?>
    in the p2 Theme entry.php
    appears to go half the way but clicking the link "Delete Post" redirects to a "WordPress Failure Notice" “Are you sure you want to do this? Please try again” . Clicking “Please try again” takes me back to previous page (the page from where I tried to delete).

    So no delete. Yet.

    Any ideas how to complete this would really be appreciated.

  3. valuser
    Posted 5 years ago #

  4. Clicknathan
    Posted 4 years ago #

    The code on that ryanpaul.ca site no longer works. same situation as valuser's 2nd comment above.

  5. Clicknathan
    Posted 4 years ago #

    Spoke too soon - that code does work for regular posts and pages, but unfortunately doesn't work for custom post types.

    Anyone know how to handle custom post types?

  6. Clicknathan
    Posted 4 years ago #

    Figured out that the reason this isn't working for Custom Post Types has something to do with the nonce URL being generated incorrectly.

    Also figured out that WP has a built in function to handle this, even with Custom Post Types.

    See this thread: http://wordpress.org/support/topic/front-end-delete-post-with-custom-post-type

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic