I've built a marketplace-type site that gives users the option to post, edit, and delete listings via get_delete_post_link()
.
For those listings, I've set up custom post types.
The problem is that only administrators are able to delete posts. The link displays correctly, but when clicked the user either is returned to the site's home page or to the current page, but nothing happens to the post.
I'm really confused about this and have spent several hours googling and trying various solutions, but none of them worked.
Among the things I tried are:
- setting
map_meta_cap
to both true and false and setting up either customcapability_type
or leaving it atpost
. - setting up a custom user role with specific
capability_type
permissions - installing the Members Plugin and assigning literally all available 181 permissions to the Subscriber role without any effect (i.e. when I
var_dump()
the capabilities it looks exactly like an admin, but behaves differently) - logging out various checks (
is_user_logged_in()
,current_user_can()
,$post->post_author == $current_user->ID
, etc.) - passing various combinations of arguments to
get_delete_post_link()
I'm at the end of my wits with this.
I'd also appreciate any advice on alternative methods of "deleting" my posts. I've also though about coding up a custom AJAX function, but was scared that it would fail because of the same strange permission problem (if it is a permission problem).
Thanks for your help!