• Will

    (@willbeing)


    We have a site that has custom roles. These roles (trial, member) have been granted the capabilities delete_posts and delete_published_posts.

    We then use a simple link to allow users to delete their own posts:

    <a onclick="return confirm('Are you sure you want to delete this scanner?')" class="btn btn-outline-danger w-100" href="<?php echo get_delete_post_link( $post->ID ) ?>">Delete Custom Scanner</a>

    Unfortunately, this only works for admins. For any other users, it redirects to the home page without deleting the post.

    Does anyone know what is incorrect here? Thank you!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You’re saying that roles with delete_posts and delete_published_posts are not working with custom posts for non-admin roles that have these? Are they able to delete regular built-in posts? If so, it may be your custom posts require custom capabilities to match.

    If they cannot even delete their own built-in posts, then they have inadequate capabilities. TBH, I’m unsure what’s truly needed. What you can do is add all plausible capabilities that relate to managing posts to trial and member roles. Then they should be able to delete. Next, remove capabilities you suspect are not required, one by one, until they can no longer delete again. Each time deletion again fails, restore what you just removed, it was needed. The goal being to provide everything needed and nothing that is not needed by process of elimination.

    Full list of default admin capabilities is here:
    https://www.ads-software.com/documentation/article/roles-and-capabilities/#administrator

Viewing 1 replies (of 1 total)
  • The topic ‘Non-Admin Roles Cannot Delete Custom Posts’ is closed to new replies.