Feature request (incl code): Check for capabilities in admin screens
-
Hello Chouby,
First I want to thank you for making this plugin. We very much appreciate the manner in which it integrates in the wordpress administrative interface.
Unfortunately there is one rather important aspect missing: capability checks.
As it is our restricted users are presented with an “add translation” button that tries to link them to a page to which they have no rights. The result is an ugly “permission denied” warning. We could create an ugly fix using late firing filters, but we’d rather do things properly and help you improve the plugin.Below you’ll find a modified version of your “admin-filters-columns.php”. The changes were made in the ‘post_column’ and ‘term_column’ methods.
In ‘post_column’ the changes comprise a CPT specific check for ‘edit_posts’ and ‘create_posts’ capabilities. (The latter are undocumented in WP, but do exist. If not explicitly specified it is the same as ‘edit_posts’). In ‘term_column’ the changes comprise a taxonomy specific check for ‘edit_terms’ and ‘manage_terms’ capabilities.
We hope you’ll consider evaluating and using this code for your next update. Thanks in advance!
[Moderator note: In future please use PasteBin to distribute large amounts of code]
https://www.ads-software.com/plugins/polylang/@moderator: Got it.
@chouby: Forgot to mention that I used a new class name for the situation where there should be a “create new” link, but the user does not have the required capabilities. As such the column is without an icon unless you add one.
- The topic ‘Feature request (incl code): Check for capabilities in admin screens’ is closed to new replies.