Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a question pretty similar to this one: Why does my custom WP role need edit_posts to edit images? but I couldn't make their solution work. And I couldn't comment there because I don't have enough reputation yet -.-

I want to my custom user role to be able to upload, manage and delete media from the media gallery, but I do not want to give them edit_post rights. They are only supposed to edit the custom post type "kunstwerke".

With my present user role the user is able to see the pictures and upload own pictures, but not able to edit pictures that are already uploaded - neither by the user himself or other users.

I did add 'upload_files' and 'edit_files' capabilities.

Here is my custom post type and custom user role:

register_post_type('albertis-kunstwerke',
    array(
    'labels' => array(
        'name' => __('Kunstwerke'),
        'singular_name' => __('Kunstwerk')),
    'public'=> true,
    'has_archive'=>true,
    'rewrite'=>array('slug' => 'kunstwerke'),
/*  'taxonomies' => array('category'), */
    'supports' => array(/*'title','categorys',*/'thumbnail'),
    'capability_type' => array('kunstwerk', 'kunstwerke'),
    'map_meta_cap' => true,
    'capabilities' => array(
        'edit_post' => 'edit_kunstwerk',
        'edit_posts' => 'edit_kunstwerke',
        'manage_post' => 'edit_kunstwerk',
        'manage_posts' => 'manage_kunstwerke',
        'read_kunstwerk' => 'read_kunstwerk',
        'read_kunstwerke' => 'read_kunstwerke',
        'edit_published_post' => 'edit_published_kunstwerk',
        'edit_others_posts' => 'edit_others_kunstwerke',
        )
));

}

//CREATION OF CUSTOM USER ROLE 
    add_role('albertis-redakteur', 'Albertis-Redakteur', array(
            'edit_kunstwerk' => true,
            'edit_kunstwerke' => true,
            'delete_kunstwerk'=> true,
            'delete_kunstwerke'=> true,
            'read_kunstwerk'=> true,
            'read_kunstwerke'=> true,
            'edit_others_kunstwerk'=> true,
            'edit_others_kunstwerke'=> true,
            'publish_kunstwerk'=> true,
            'publish_kunstwerke'=> true,
            'edit_published_kunstwerk'=> true,
            'edit_published_kunstwerke'=> true,
            'delete_published_kunstwerk'=> true,
            'delete_published_kunstwerke'=> true,
            'edit_pages'=> true,
            'publish_pages'=> true,
            'delete_pages'=> true,
            'delete_others_pages'=> true,
            'delete_published_pages'=> true,
            'edit_published_pages'=> true,
            'edit_dashboard'=> true,
            'upload_files'=> true,
            'edit_files'=> true,
            'activate_plugins'=> true,
            'update_core'=> true,
            'update_plugins'=> true,
            'edit_theme_options'=>true,
    )) ;

Help is greatly appreciated. Also: I don't want to use plugins for this, as part of the project requirements.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.