不使用自定义帖子类型的功能

时间:2017-11-02 作者:Michael

我创建了一个称为警报的自定义帖子类型。我希望编辑器用户能够拥有发布和编辑警报的完全权限。我复制了管理员的所有功能以满足此要求。然而,拥有自定义帖子类型的所有功能已经删除了发布权限,这是出乎意料的。这是我的自定义帖子类型配置。删除发布和编辑警报的功能是我做错了什么?

        register_post_type(\'alert\', array(
        \'label\'     => \'Alerts\',
        \'public\'    => true,
        \'capability_type\' => \'alert\',
        \'capabilities\'  => array(
            \'delete_others_pages\'       => \'delete_others_pages\',
            \'delete_others_posts\'       => \'delete_others_posts\',
            \'delete_pages\'              => \'delete_pages\',
            \'delete_posts\'              => \'delete_posts\',
            \'delete_private_pages\'      => \'delete_private_pages\',
            \'delete_private_posts\'      => \'delete_private_posts\',
            \'delete_published_pages\'    => \'delete_published_pages\',
            \'delete_published_posts\'    => \'delete_published_posts\',
            \'edit_others_pages\'         => \'edit_others_pages\',
            \'edit_others_posts\'         => \'edit_others_posts\',
            \'edit_pages\'                => \'edit_pages\',
            \'edit_posts\'                => \'edit_posts\',
            \'edit_private_pages\'        => \'edit_private_pages\',
            \'edit_private_posts\'        => \'edit_private_posts\',
            \'edit_published_pages\'      => \'edit_published_pages\',
            \'edit_published_posts\'      => \'edit_published_posts\',
            \'publish_pages\'             => \'publish_pages\',
            \'publish_posts\'             => \'publish_posts\',
            \'read_private_pages\'        => \'read_private_pages\',
            \'read_private_posts\'        => \'read_private_posts\',
            \'read\'                      => \'read\',
            \'activate_plugins\'          => \'activate_plugins\',
            \'edit_dashboard\'            => \'edit_dashboard\',
            \'edit_theme_options\'        => \'edit_theme_options\',
            \'export\'                    => \'export\',
            \'import\'                    => \'import\',
            \'list_users\'                => \'list_users\',
            \'manage_categories\'         => \'manage_categories\',
            \'manage_links\'              => \'manage_links\',
            \'manage_options\'            => \'manage_options\',
            \'moderate_comments\'         => \'moderate_comments\',
            \'promote_users\'             => \'promote_users\',
            \'remove_users\'              => \'remove_users\',
            \'switch_themes\'             => \'switch_themes\',
            \'upload_files\'              => \'upload_files\',
            \'customize\'                 => \'customize\',
            \'delete_site\'               => \'delete_site\'
        )
    ));

1 个回复
SO网友:Drupalizeme

您应该将CPT功能映射到capability_type 这种方式可以让WP了解您想要做什么。尝试edit_$cap_type (其中$cap\\u type=警报)

结束

相关推荐

Remove TEXT EDITOR form page

我正在寻找一种从页面中删除文本编辑器的方法,因为我正在使用Beaver Builder插件(用于构建我的页面)。就像你在下图中看到的,我有两个标签。我想删除文本编辑器选项卡(红色)。提前谢谢。