最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

capabilities - Admin: Get all user for Custom Role

programmeradmin1浏览0评论

I made a custom post type evenement with these capabilities. Here, I just put the capabilities parameters.

'capability_type' => 'evenement',
'map_meta_cap' => true,
'capabilities' => array(
    // meta caps (don't assign these to roles)
    'edit_post' => 'edit_evenement',
    'read_post' => 'read_evenement',
    'delete_post' => 'delete_evenement',

    // primitive/meta caps
    'create_posts' => 'create_evenements',

    // primitive caps used outside of map_meta_cap()
    'edit_posts'  => 'edit_evenements',
    'edit_others_posts'  => 'manage_evenements',
    'publish_posts' => 'publish_evenements',
    'read_private_posts' => 'read',

    // primitive caps used inside of map_meta_cap()
    'read' => 'read',
    'delete_posts' => 'delete_evenements',
    'delete_private_posts' => 'delete_private_evenements',
    'delete_published_posts' => 'delete_published_evenements',
    'delete_others_posts' => 'manage_evenements',
    'edit_private_posts' => 'edit_evenements',
    'edit_published_posts' => 'edit_evenements'
    )

And for the add_cap function I use

// CPT event
function manage_event_capabilities() {
    $admin = get_role('administrator');
    $institution = get_role('institution');
    $institutionspecial = new WP_User(105);
    $caps = array(
        'create_evenements',
        'delete_evenements',
        'delete_private_evenements',
        'delete_published_evenements',
        'edit_evenements',
        'manage_evenements',
        'publish_evenements'
    );

    foreach($caps as $cap) {
        $admin->add_cap($cap);
    }

    // $admin->remove_cap('exec_php');

    // basique
    $institution->add_cap('upload_files');

    // event
    $institution->add_cap('create_evenements');
    $institution->add_cap('edit_evenements');
    $institution->remove_cap('publish_evenements');
    $institution->add_cap('delete_evenements');
    $institution->add_cap('special_institution');


}

Everything works perfect, except for one think. The admin, can not list all the user who have this custom role institution. If I want to change the author, I just have the current one (with institution role) or all the normal author of the website.

Could you help me? Thanks

I made a custom post type evenement with these capabilities. Here, I just put the capabilities parameters.

'capability_type' => 'evenement',
'map_meta_cap' => true,
'capabilities' => array(
    // meta caps (don't assign these to roles)
    'edit_post' => 'edit_evenement',
    'read_post' => 'read_evenement',
    'delete_post' => 'delete_evenement',

    // primitive/meta caps
    'create_posts' => 'create_evenements',

    // primitive caps used outside of map_meta_cap()
    'edit_posts'  => 'edit_evenements',
    'edit_others_posts'  => 'manage_evenements',
    'publish_posts' => 'publish_evenements',
    'read_private_posts' => 'read',

    // primitive caps used inside of map_meta_cap()
    'read' => 'read',
    'delete_posts' => 'delete_evenements',
    'delete_private_posts' => 'delete_private_evenements',
    'delete_published_posts' => 'delete_published_evenements',
    'delete_others_posts' => 'manage_evenements',
    'edit_private_posts' => 'edit_evenements',
    'edit_published_posts' => 'edit_evenements'
    )

And for the add_cap function I use

// CPT event
function manage_event_capabilities() {
    $admin = get_role('administrator');
    $institution = get_role('institution');
    $institutionspecial = new WP_User(105);
    $caps = array(
        'create_evenements',
        'delete_evenements',
        'delete_private_evenements',
        'delete_published_evenements',
        'edit_evenements',
        'manage_evenements',
        'publish_evenements'
    );

    foreach($caps as $cap) {
        $admin->add_cap($cap);
    }

    // $admin->remove_cap('exec_php');

    // basique
    $institution->add_cap('upload_files');

    // event
    $institution->add_cap('create_evenements');
    $institution->add_cap('edit_evenements');
    $institution->remove_cap('publish_evenements');
    $institution->add_cap('delete_evenements');
    $institution->add_cap('special_institution');


}

Everything works perfect, except for one think. The admin, can not list all the user who have this custom role institution. If I want to change the author, I just have the current one (with institution role) or all the normal author of the website.

Could you help me? Thanks

Share Improve this question asked Oct 13, 2014 at 10:17 GregoireGregoire 514 bronze badges 2
  • I am not sure what you are asking. – s_ha_dum Commented Oct 13, 2014 at 17:42
  • I find the solution and put the link related. That would be easier to undertand for you. Thanks :) – Gregoire Commented Oct 14, 2014 at 5:18
Add a comment  | 

1 Answer 1

Reset to default 1

I find the solution, that's a WordPress 4 year's bug. Here is the Summary from DrewAPicture

changed from manually created user roles not showing in author dropdown irregardless of assigned capabilities to Manually created user roles not showing in author dropdown regardless of assigned capabilities

Please see ticket 16841 for more details.

The only simple solution I find is to change the author with a custom role to the normal Author role. Then attribute the custom post to this author and change back the same author with the custom role.

发布评论

评论列表(0)

  1. 暂无评论