Glad to see you jazzed. ?? I think “yes” to everything you’ve said.
To be clear: A capability is just a unique flag. A role is a collection of specific flags. Any post gets a status that has its related _view_ and _edit_ permissions.
When any post is requested, hook the related action or filter. For example, load-post.php
, wp_before_admin_bar_render
, post_row_actions
, page_row_actions
, manage_posts_columns
, manage_posts_custom_column
, edit_form_top
, etc.
In those hooks, generate the cap for the status, maybe $cap='ext_status_view-'.get_post_status($post->ID)
. Then use current_user_can($cap)
to see if the user/role has permission to do that function.
I’d standardize that permission check in a consistent function and then call it from various hooks to determine “can this user view or edit on this post at this time?”
The ability to view or edit the list of statuses can itself be given a capability ext_status_edit
or ext_status_view
. If the user has the administrator role and the manage_options
permission, then there’s no need to check plugin-specific options. But if the user is not an admin, then these caps can be checked to determine if the menu option is available at all, or if the user has the right to submit a change from the admin page if they can see it. I dunno about you but personally I wouldn’t want anyone but the administrator to modify taxonomy or statuses, so inititally it would be safe to just check manage_options
– I haven’t looked but you are probably already doing that. ??
As to “selection of all roles per status”, sure, it would be nice to see a list of the roles and maybe the users in those roles who have view/edit permissions for a selected status. I can picture a grid with status across the top and role down the left side. In fact this is exactly how some issue tracking systems do this – and some allow for editing the permissions in that grid. For purposes here, it’s seems enough to suggest that admins use a plugin like User Role Editor to view and manage caps for specific roles.