I registered a custom post type ("playlist") in my plugin. I've read a lot about roles and capabilities but this is quite difficult to understand completely... The thing I would like to achieve is to CLONE capabilities for a post type, by roles : In my case, I would like to get the capabilities from "post" (by role), and assign them to my custom post type ("playlist")
I don't want to use "capability_type" like below because I don't want to assign the "post" capabilities to my "playlist" post type, I want it to have their own capabilties but with the same default values for each role.
function register_post_type() {
$args = array(
...
'capability_type' => 'post', //I think I don't need this
...
);
register_post_type( 'playlist', $args );
)
So I guess I need something more like that :
function register_post_type() {
$args = array(
...
'capability_type' => 'playlist',
'map_meta_cap' => true,
'capabilities' => array(
'edit_post' => 'edit_playlist',
'read_post' => 'read_playlist',
'delete_post' => 'delete_playlist',
'create_posts' => 'create_playlists',
'edit_posts' => 'edit_playlists',
'edit_others_posts' => 'manage_playlists',
'publish_posts' => 'manage_playlists',
'read_private_posts' => 'read',
'read' => 'read',
'delete_posts' => 'manage_playlists',
'delete_private_posts' => 'manage_playlists',
'delete_published_posts' => 'manage_playlists',
'delete_others_posts' => 'manage_playlists',
'edit_private_posts' => 'edit_playlists',
'edit_published_posts' => 'edit_playlists'
),
...
);
register_post_type( 'playlist', $args );
)
but after that I would need to run a function to assign those capabilities to each role, based on the "post" capabilities". See what I mean ?
Do you have an idea of how I could achieve this ?
Thanks !
PS : useful link : http://justintadlock.com/archives/2013/09/13/register-post-type-cheat-sheet