我在我的插件中注册了一个自定义帖子类型(“播放列表”)。我已经阅读了很多关于角色和能力的内容,但这很难完全理解......我想要实现的是按角色克隆帖子类型的能力:就我而言,我想获得“帖子”(按角色)的功能,并将它们分配给我的自定义帖子类型(“播放列表”)
我不想像下面那样使用“capability_type”,因为我不想将“发布”功能分配给我的“播放列表”发布类型,我希望它有自己的功能,但每个角色都有相同的默认值.
function register_post_type() {
$args = array(
...
'capability_type' => 'post', //I think I don't need this
...
);
register_post_type( 'playlist', $args );
)
所以我想我需要更多类似的东西:
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 );
)
但在那之后,我需要运行一个函数来根据“发布”功能将这些功能分配给每个角色。明白我的意思吗?
你知道我怎么能做到这一点吗?
谢谢 !
PS:有用的链接:http: //justintadlock.com/archives/2013/09/13/register-post-type-cheat-sheet