After hours of fighting to get this to work, it was just a matter of changing delete_posts
to delete_post
.
So, in it’s entirety this would be:
current_user_can('delete_posts', $post_id);
to
current_user_can('delete_post', $post_id);
current_user_can
does accept a second parameter. Though it’s weird that the function declaration in capabilities.php
does not define a second parameter as pointed out by @amit. May be someone can clarify why it is so.