我的wordpress主题有一个自定义的帖子类型。仅允许编辑(及更高级别)使用此帖子类型。
我是这样做的:
function add_capability($role,$cap) {
$role_obj = get_role($role); // get the the role object
$role_obj -> add_cap($cap); // add $cap capability to this role object
}
function set_cpt() {
add_capability(\'editor\', \'edit_cpt\');
add_capability(\'editor\', \'read_cpt\');
add_capability(\'editor\', \'delete_cpt\');
add_capability(\'editor\', \'edit_cpt\');
add_capability(\'editor\', \'edit_cpt\');
add_capability(\'editor\', \'publish_cpt\');
add_capability(\'editor\', \'read_cpt\');
}
add_action(\'init\', \'set_cpt\');
(我想)在Wordpress 3.1中,这已经足够了-所有的编辑
and higher 有权使用post类型罢工>
现在,在Wordpress 3.2中only 编辑有权使用帖子类型。
是否有办法授予角色X及更高级别的权限,或者我必须提及每个角色?
非常感谢。
[编辑]
事实上,我发现这以前从未奏效过。但还有其他方法吗?