我已经声明了一个新的post类型,它在管理菜单上可见:function create\\u post\\u type(){
register_post_type( \'employer_fm\',
array(
\'labels\' => array(
\'name\' => _x(\'Employer\', \'Employers\'),
\'singular_name\' => _x(\'Employer \', \'domain\'),
),
\'public\' => true,
\'capability_type\' => array(\'employer\',\'employers\',\'adminstrator\'),
\'supports\' => array(\'title\',\'author\',\'thumbnail\',\'page-attributes\'),
\'capabilities\' => array(
\'read_post\' => \'read_employer\',
\'publish_posts\' => \'publish_employer\',
\'edit_posts\' => \'edit_employers\',
\'edit_others_posts\' => \'edit_others_employer\',
\'delete_posts\' => \'delete_employer\',
\'delete_others_posts\' => \'delete_others_employer\',
\'edit_others_pages\' => \'edit_others_employer_page\',
\'read_private_posts\' => \'read_private_employer\',
\'edit_post\' => \'edit_employer\',
\'delete_post\' => \'delete_employer\',
),
)
);
}
我还声明了角色:
$result = add_role(
\'employer\',
__( \'Employer\' ),
array(
\'edit_employer\' => true,
\'edit_employers\' => true,
\'publish_employer\' => true,
\'read_employer\' => true,
\'delete_employer\'=> true,
\'edit_others_employer\' => false,
\'delete_others_employer\' => false,
\'edit_others_employer_page\' => false
)
);
$role = get_role( \'administrator\' );
$role->add_cap( \'edit_employer\' );
$role->add_cap( \'read_employer\' );
$role->add_cap( \'delete_employer\' );
$role->add_cap( \'edit_employers\' );
$role->add_cap( \'publish_employer\' );
如果
\'map_meta_cap\' => true,
用户只能查看和发布帖子(包括管理员),如果未设置,则所有用户都可以编辑所有雇主类型的帖子。
如何预防employer
编辑其他帖子的用户类型?