编辑页面时,一个作者未显示在作者下拉列表中

时间:2012-10-04 作者:Christian

如果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,
    );
}

2 个回复
最合适的回答,由SO网友:Christian 整理而成

答案如下:Users with custom roles not showing in post author select box

我进行了测试,它可以工作:

to add a level_1 cap to your role.

It\'s PITA, considering how user levels have been deprecated so long ago, but there you go

SO网友:dzogchen

不确定,但问题是否与将“复数”拼写为“复数”有关??我知道您在函数中使用它作为变量名,但您也在cjg\\U add\\u role函数中引用它。。。

结束

相关推荐

Pages_Links()在earch.php中不能正常工作吗?

我在搜索中使用这个。php模板…<div class=\"pagination\"> <?php echo get_pagination_links(); ?> </div> 这是函数…function get_pagination_links() { global $wp_query; $big = 999999999; return paginate_links( array