【发布时间】:2014-09-29 17:35:30
【问题描述】:
我在我的插件中注册了一个自定义帖子类型(“播放列表”)。 我已经阅读了很多关于角色和能力的内容,但这很难完全理解...... 我想要实现的是按角色克隆帖子类型的功能: 就我而言,我想从“帖子”(按角色)中获取功能,并将它们分配给我的自定义帖子类型(“播放列表”)
我不想像下面那样使用“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
【问题讨论】:
标签: wordpress custom-post-type role capability