我用这些功能制作了一个自定义的post-type evement。在这里,我只是把能力参数。
\'capability_type\' => \'evenement\',
\'map_meta_cap\' => true,
\'capabilities\' => array(
// meta caps (don\'t assign these to roles)
\'edit_post\' => \'edit_evenement\',
\'read_post\' => \'read_evenement\',
\'delete_post\' => \'delete_evenement\',
// primitive/meta caps
\'create_posts\' => \'create_evenements\',
// primitive caps used outside of map_meta_cap()
\'edit_posts\' => \'edit_evenements\',
\'edit_others_posts\' => \'manage_evenements\',
\'publish_posts\' => \'publish_evenements\',
\'read_private_posts\' => \'read\',
// primitive caps used inside of map_meta_cap()
\'read\' => \'read\',
\'delete_posts\' => \'delete_evenements\',
\'delete_private_posts\' => \'delete_private_evenements\',
\'delete_published_posts\' => \'delete_published_evenements\',
\'delete_others_posts\' => \'manage_evenements\',
\'edit_private_posts\' => \'edit_evenements\',
\'edit_published_posts\' => \'edit_evenements\'
)
对于我使用的add\\u cap函数
// CPT event
function manage_event_capabilities() {
$admin = get_role(\'administrator\');
$institution = get_role(\'institution\');
$institutionspecial = new WP_User(105);
$caps = array(
\'create_evenements\',
\'delete_evenements\',
\'delete_private_evenements\',
\'delete_published_evenements\',
\'edit_evenements\',
\'manage_evenements\',
\'publish_evenements\'
);
foreach($caps as $cap) {
$admin->add_cap($cap);
}
// $admin->remove_cap(\'exec_php\');
// basique
$institution->add_cap(\'upload_files\');
// event
$institution->add_cap(\'create_evenements\');
$institution->add_cap(\'edit_evenements\');
$institution->remove_cap(\'publish_evenements\');
$institution->add_cap(\'delete_evenements\');
$institution->add_cap(\'special_institution\');
}
一切都很完美,除了一个想法。管理员无法列出具有此自定义角色的所有用户
institution
. 如果我想更改作者,我只需要当前作者(具有机构角色)或所有
normal 网站作者。
你能帮帮我吗?谢谢