我创建了一个名为product
并分配了一个新角色manager
为了它。除了媒体上传器product
. 我甚至可以直接在add media
部分所以,我开始用默认值进行测试author
, 还是一样的错误!令人惊讶的是author
可以在默认情况下成功上载图像post
, 不在product
!
错误消息显示:An Error occurred in the upload. Please Try again later.
以下是自定义帖子类型的代码:
function cpt_product() {
$slug = \'product\';
$labels = array( //all the custom labels );
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'menu_position\' => \'5.1\',
\'public\' => true,
\'has_archive\' => true,
\'supports\' => array( \'title\', \'editor\', \'author\', \'excerpt\', \'custom-fields\', \'revisions\' ),
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'capability_type\' => $slug,
\'capabilities\' => array(
\'edit_post\' => \'edit_\' . $slug,
\'read_post\' => \'read_\' . $slug,
\'delete_post\' => \'delete_\' . $slug,
\'edit_posts\' => \'edit_\' . $slug . \'s\',
\'edit_others_posts\' => \'edit_others_\' . $slug . \'s\',
\'publish_posts\' => \'publish_\' . $slug . \'s\',
\'read_private_posts\' => \'read_private_\' . $slug . \'s\',
\'delete_posts\' => \'delete_\' . $slug . \'s\',
\'delete_private_posts\' => \'delete_private_\' . $slug . \'s\',
\'delete_published_posts\' => \'delete_published_\' . $slug . \'s\',
\'delete_others_posts\' => \'delete_others_\' . $slug . \'s\',
\'edit_private_posts\' => \'edit_private_\' . $slug . \'s\',
\'edit_published_posts\' => \'edit_published_\' . $slug . \'s\'
),
\'map_meta_cap\' => true
);
register_post_type( $slug, $args );
}
下面是自定义角色的代码
manager
function add_manager () {
$role_manager = \'manager\' ;
$displayname_manager = \'Manager\';
$capabilities_manager = array (
\'read\' => true,
\'edit_product\' => true,
\'read_product\' => true,
\'delete_product\' => false,
\'edit_products\' => true,
\'edit_others_products\' => true,
\'publish_products\' => true,
\'read_private_products\' => true,
\'delete_products\' => false,
\'delete_private_products\' => false,
\'delete_published_products\' => false,
\'delete_others_products\' => false,
\'edit_private_products\' => true,
\'edit_published_products\' => true,
\'edit_posts\' => true,
\'upload_files\' => true
);
create_custom_role ( $role_manager, $displayname_manager, $capabilities_manager );
}
add_action(\'admin_init\', \'add_manager\');
function create_custom_role ( $rolename, $roledisplayname, $capabilities ) {
if ( get_role ( $rolename ) ) {
return 0;
}
else {
add_role ( $rolename, $roledisplayname, $capabilities );
}
}
现在我完全迷失在这里,找不到解决办法!谁能帮帮我,告诉我我错过了什么,或者做错了什么(