按要求。。。
add_action( \'init\', \'create_my_post_types\' );
function create_my_post_types() {
register_post_type(
\'name_of_your_post_type_singular\',
array(
\'public\' => true,
\'capability_type\' => \'name_of_your_post_type_singular\'
),
)
);
}
add_action(\'admin_init\', \'give_user_read\', 10, 0);
function give_user_edit() {
if(current_user_can(\'edit_others_posts\')) {
global $wp_roles;
$wp_roles->add_cap(\'author\',\'read_name_of_your_post_type_plural\' );
$wp_roles->add_cap(\'editor\',\'read_name_of_your_post_type_plural\' );
etc. etc.
}
}
我已经为用户角色添加了读取功能。因为我没有给任何人编辑或删除。。他们不会接受的。因为我已经给了作者和编辑阅读权限,他们将拥有它。
如果您不确定这些功能是什么,当您添加上面的类型时,您将生成下面的功能
\'capabilities\' => array(
\'publish_posts\' => \'publish_name_of_your_post_type_plural\',
\'edit_posts\' => \'edit_name_of_your_post_type_plural\',
\'edit_others_posts\' => \'edit_others_name_of_your_post_type_plural\',
\'delete_posts\' => \'delete_name_of_your_post_type_plural\',
\'delete_others_posts\' => \'delete_others_name_of_your_post_type_plural\',
\'read_private_posts\' => \'read_private_name_of_your_post_type_plural\',
\'edit_post\' => \'edit_name_of_your_post_type_singular\',
\'delete_post\' => \'delete_name_of_your_post_type_singular\',
\'read_post\' => \'read_name_of_your_post_type_singular\'
)