如何发布自定义角色用户的自定义岗位类型,而不是提交审阅?

时间:2014-09-12 作者:Overdose

我创建了一个自定义的post类型“openproject”,在这里我设置了功能。

function custom_post_openproject() {
    $labels = array(
        \'name\' => \'openproject\',
        \'add_new\' => \'Add new openproject\',
        \'add_new_item\' => \'Add new openproject\',
        \'edit_item\' => \'Edit openproject\',
        \'menu_name\' => \'Openproject\'
    );
    $map_meta_cap = true;
    $capability_type = \'openproject\';
    $capabilities = array(
        \'edit_files\' => \'edit_files\',
        \'upload_files\' => \'upload_files\',
        \'edit_post\' => \'openproject_edit\',
        \'read_post\' => \'openproject_read\',
        \'delete_post\' => \'openproject_delete\',
        \'edit_posts\' => \'openprojects_edit\',
        \'edit_others_posts\' => \'openprojects_edit_others\',
        \'publish_posts\' => \'openprojects_publish\',
        \'delete_posts\' => \'openprojects_delete\',
        \'delete_published_posts\' => \'openprojects_delete_published\',
        \'delete_others_posts\' => \'openprojects_delete_others\',
        \'edit_publish_posts\' => \'openprojects_edit_publish\',
    );

    $args = array(
        \'labels\' => $labels,
        \'public\' => true,
        \'show_in_nav_menus\' => true,
        \'show_ui\' => true,
        \'show_in_menu\' => true, 
        \'capability_type\' => $capability_type,
        \'capabilities\' => $capabilities,
        \'map_meta_cap\' => $map_meta_cap,
        \'hierarchical\' => false,
        \'with_front\' => false,
        \'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comment\'),
        \'has_archive\' => false,
        \'rewrite\' => array(\'slug\'=>\'openproject\'),
    );
    register_post_type( \'openproject\', $args );
}
我已将此自定义帖子类型分配给自定义角色“openproject\\u access”

function openproject_user_can(){
    $newrole = add_role( 
        \'openproject_access\', 
        \'Membre OpenProject\', 
        array(
            \'read\'=> true,

            \'openprojects_publish\' => true,
            \'openproject_read\' => true,
            \'openproject_edit\' => true,
            \'openprojects_edit_others\' => false,
            \'openprojects_edit\' => true,
            \'openproject_delete\' => true,
            \'openprojects_delete\' => true,
            \'openprojects_delete_others\' => false,

            \'edit_comment\' => false,
            \'moderate_comments\' => false,
            \'edit_files\' => true,
            \'upload_files\' => true,
        )
    ); 
}
我创建了一个具有此角色的用户,但当我以此用户身份登录时,问题是当我创建一个新的“openproject”时,我只有“提交以供审阅”按钮,而没有“发布”!

我想我已经在我的设置中正确设置了发布功能(\'publish_posts\' => \'openprojects_publish\', 在CPT和\'openprojects_publish\' => true, 在角色中)我错过了什么?

EDITTo complete,我已经在新安装的WP 4.0上尝试了这一点。在我的wp\\u usermeta中a:1:{s:18:"openproject_access";b:1;} 对于该用户的能力

1 个回复
SO网友:Joy Reynolds

您的map\\u meta\\u cap为true,但您自己使用“功能”和向后语法定义功能。

映射功能时,动词在开头,名词在结尾,因此“edit\\u post”功能将是“edit\\u openproject”。

结束

相关推荐