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 created a custom post type:

add_action( 'init', 'artwork_feature');
function artwork_feature() {
register_post_type( 'artwork',
    array(
    'labels' => array(
            'name' => __( 'Artwork' ),
            'singular_name' => __( 'Artwork' )
        ),
    'public' => true,
    'exclude_from_search' => false,
    'capability_type' => 'artwork',
    'supports' => array('custom-fields', 'comments', 'title', 'editor', 'thumbnail'),
    'capabilities' => array(
            'publish_posts' => 'publish_artworks',
            'edit_posts' => 'edit_artworks',
            'edit_others_posts' => 'edit_others_artworks',
            'delete_posts' => 'delete_artworks',
            'delete_others_posts' => 'delete_others_artworks',
            'read_private_posts' => 'read_private_artworks',
            'edit_post' => 'edit_artwork',
            'delete_post' => 'delete_artwork',
            'read_post' => 'read_artwork',
        ),
    'map_meta_cap' => true,
    'taxonomies' => array('post_tag'),
    'has_archive' => true   
    )
);

}

Then I installed the MEMBERS plugin, created a new role 'Artists' and went into the role and clicked 'Add New Capabilities'. I added:

  1. edit_artworks
  2. delete_artworks

Then in my Admin Role I added:

  1. edit_artworks
  2. delete_artworks
  3. publish_artworks
  4. edit_others_artworks
  5. delete_others_artworks
  6. read_private_artworks

Also, following a tutorial I added this to the functions.php:

//Set roles to meta capabilities
add_filter( 'map_meta_cap', 'my_map_meta_cap', 10, 4 );

function my_map_meta_cap( $caps, $cap, $user_id, $args ) {

/* If editing, deleting, or reading a artwork, get the post and post type object. */
if ( 'edit_artwork' == $cap || 'delete_artwork' == $cap || 'read_artwork' == $cap ) {
    $post = get_post( $args[0] );
    $post_type = get_post_type_object( $post->post_type );

    /* Set an empty array for the caps. */
    $caps = array();
}

/* If editing a artwork, assign the required capability. */
if ( 'edit_artwork' == $cap ) {
    if ( $user_id == $post->post_author )
        $caps[] = $post_type->cap->edit_posts;
    else
        $caps[] = $post_type->cap->edit_others_posts;
}

/* If deleting a artwork, assign the required capability. */
elseif ( 'delete_artwork' == $cap ) {
    if ( $user_id == $post->post_author )
        $caps[] = $post_type->cap->delete_posts;
    else
        $caps[] = $post_type->cap->delete_others_posts;
}

/* If reading a private artwork, assign the required capability. */
elseif ( 'read_artwork' == $cap ) {

    if ( 'private' != $post->post_status )
        $caps[] = 'read';
    elseif ( $user_id == $post->post_author )
        $caps[] = 'read';
    else
        $caps[] = $post_type->cap->read_private_posts;
}

/* Return the capabilities required by the user. */
return $caps;

}

Now when I create artworks and publish them I can only View them in both roles. I am missing the Edit, Quick Edit, & Trash links.

Can someone help?

share|improve this question

closed as off-topic by Rarst Mar 28 at 18:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Well wouldn't you know it, after I posted this I figured it out. I added edit_published_artworks and it worked! –  Brian Mar 27 at 21:50