WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#51291 new enhancement

Add filter to show post list table `column_cb` even without `edit_post` capability

Reported by: coreyw Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: needs-patch good-first-bug
Focuses: administration Cc:

Description

Right now the checkbox in the posts list table only shows if the user can edit the post. I am working on a plugin that allows posts to be archived, which means they are not visible publicly, and are no longer editable (until unarchived).

To do this, I have used the map_meta_cap filter to disallow the edit_post capability if the current post_status is archive. This is great because the post in the table no longer has a link to edit or quick edit, and if you use a direct URL to edit the post a message shows to user saying they are not allowed (having a custom message here that says the post is archived would be good, maybe there is already an easy way to do so?).

The problem though, is that the checkbox also is gone in the list table. This does not allow a user to select archived posts and then use the "Unarchive" bulk action.

Currently to get around this, I am looping over debug_backtrace() to check if the current_user_can('edit_post', $id) call is coming from the column_cb function or not and returning the appropriate value. Obviously this is not preferred though.

There may be a better way than simply allowing a filter for the column_cb as well, but hopefully this explains the end goal.

Change History (1)

#1 @johnbillion
3 months ago

  • Component changed from Administration to Posts, Post Types
  • Focuses administration added
  • Keywords needs-patch good-first-bug added

Yes please. I've had a need for this too.

Note: See TracTickets for help on using tickets.