如何增加作者角色权限以添加类别?
欢迎使用其他解决方案。我们只需要来宾作者能够添加类别,同时确保现有的适当类别还不存在。
如何增加作者角色权限以添加类别?
欢迎使用其他解决方案。我们只需要来宾作者能够添加类别,同时确保现有的适当类别还不存在。
最简单的方法是使用如下插件Capability Manager 或User Role Editor
应该从内部工作functions.php
function add_manage_cat_to_author_role()
{
if ( ! current_user_can( \'author\' ) )
return;
// here you should check if the role already has_cap already and if so, abort/return;
if ( current_user_can( \'author\' ) )
{
$GLOBALS[\'wp_roles\']->add_cap( \'author\',\'manage_categories\' );
}
}
add_action( \'admin_init\', \'add_manage_cat_to_author_role\', 10, 0 );
我需要对类别列表输出进行更多控制,因此我使用get_categories(), 而不是wp_list_categories().此函数返回按特定属性排序的对象的平面数组。如何从中构建层次结构列表,如wp_list_categories() 做