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

2
  • I am not sure what you are asking.
    – s_ha_dum
    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
    Oct 14, 2014 at 5:18

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.