如果USER01处于我的自定义角色“mycustomrole”,则在编辑页面时,他不会显示在作者下拉列表中。
如果我改变他作为作者的角色,并添加相同的自定义和非自定义能力,他就会显示在列表中。
我通过编程创建了这个角色,如下所示。
为了在我的作者列表中看到它,有什么特别的东西要添加吗?
function cjg_4cast_addroles(){
cjg_add_role(\'mycustomrole\',\'My Custom Role\',array(
array(\'singular\' => \'side-add\', \'plural\' => \'side-adds\'),
array(\'singular\' => \'partner\', \'plural\' => \'partners\')
),
array(
\'read\' => true,
\'upload_files\' => true,
\'edit_files\' => true,
\'edit_pages\' => true,
\'edit_published_pages\' => true,
\'publish_pages\' => true,
\'delete_pages\' => true,
\'delete_private_pages\' => true,
\'edit_private_pages\' => true,
\'read_private_pages\' => true,
\'publish_posts\' => true,
\'edit_posts\' => true,
\'edit_published_posts\' => true,
)
);
}
function cjg_add_role($role_name,$role_name_display,$custom_type_slugs,$capabilities){
foreach($custom_type_slugs as $custom_type_slug){
$capabilities = array_merge($capabilities,
cjg_capabilitiesarray_fromslug($custom_type_slug[\'singular\'],$custom_type_slug[\'plural\'])
);
}
add_role( $role_name, $role_name_display, $capabilities);
}
function cjg_capabilitiesarray_fromslug($singular,$plural){
return array(
"edit_$singular" => true,
"read_$singular" => true,
"delete_$singular" => true,
"edit_$plural" => true,
"edit_others_$plural" => true,
"publish_$plural" => true,
"read_private_$plural" => true,
);
}