Is there a hook which would enable an admin to disallow editors and authors from creating new categories for posts? Only admins should be able to create new categories. Editors & authors need to pick from what they're given.
Is there a hook which would enable an admin to disallow editors and authors from creating new categories for posts? Only admins should be able to create new categories. Editors & authors need to pick from what they're given.
Share Improve this question edited Jul 24, 2019 at 16:15 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Jul 24, 2019 at 15:54 CDToadCDToad 511 silver badge5 bronze badges1 Answer
Reset to default 0This has to do with the capabilities tied to the current user role.
In your case you are looking for manage_categories capability.
Option 1) Install a Plugin, which enables you to edit the capabilites (Just "Members", best plugin for that in my opinion, or "user role editor".)
Option 2) WordPress has this separation already build in.
"Editors" can manage categories. "Authors" can not!
So, you only would have to give the users the "Author" role that should be enough to restrict it.
Option 3) Do it via code in your functions.php with something like:
<?php
global $pagenow, $typenow;
if(($pagenow === 'edit-tags.php') && $typenow === 'taxonomy') {
if(!current_user_can('manage_categories')) {
// Do whatever you want them to see.. redirect to home or whatever
return false;
}
}
I havent' tested the code above, but that should be the direction to go.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745298411a4621284.html
评论列表(0条)