How to publish custom post type for custom role user and not “submit for review”?

Question

I’ve created a custom post type ‘openproject’, where i set capabilities.

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 );
}

I assigned this custom post type to a custom role ‘openproject_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,
        )
    ); 
}

I’ve created a user with this role, but when i’m logged in as this user, the problem is when i create a new ‘openproject’, i have only “Submit for review” button and not “Publish” !

I think i have set the publish capability properly in my setting ('publish_posts' => 'openprojects_publish', in CPT and 'openprojects_publish' => true, in the role)
What i have missed ?

EDIT
To be complete, i’ve tried this on a fresh install of WP 4.0.
In my wp_usermeta i’ve got a:1:{s:18:"openproject_access";b:1;} for the capability of that user

0
, Overdose 7 years 2014-09-12T03:19:11-05:00 0 Answers 83 views 0

Leave an answer

Browse
Browse