我终于成功了update an old WP 3.3.1 site to WP 4.1 虽然问题很少,但在文件上传方面似乎出现了一个意想不到的变化。
在插件的WP 3.3.1版本中,我通过“read”和“upload\\u files”为自定义角色启用了上载。
注意:这适用于以下内容:NOT 后驱动。这只是编辑我想为一些custom db tables. 这个wp_editor 调用的内容显式设置为“”。我正在使用缓冲破解来重新定位编辑器,详细内容如下:https://wordpress.stackexchange.com/a/66345
// capture the editor for later use...
// HACK: https://wordpress.stackexchange.com/a/66345
ob_start();
wp_editor(
\'\',
\'xyz-note-editor\',
array(
\'textarea_rows\' => \'10\',
)
);
$editor = ob_get_clean();
// ...
$edit_form_template = str_replace(\'{{NotesEditor}}\', $editor, $edit_form_template);
更新到WP 4.1后,所有works for Editors and Administrators.It fails for Authors, Contributors and my custom role 错误为:“您没有将文件附加到此帖子的权限。”
(当以编辑器或管理员身份成功上载时,“post”似乎是一个不相关的自定义post类型实例,上载的媒体将分配给该实例。)
除了重建东西,或者寻找一些插件(比如JustinTadlock的成员,StackExchange上其他地方推荐的),我陷入了困境。
Why can Editors circumvent upload restrictions in this case?
我尝试将编辑器(及以下)的编辑/发布/读取权限分配给自定义角色,但没有成功-基于http://codex.wordpress.org/Roles_and_Capabilities.add_role(
XxYyConfig::USER_ROLE(),
\'Custom Data Manager\',
array(
\'read\' => true,
// ADDED: to address changes in how WordPress "Add Media" works - re: "You don\'t have permission to attach files to this post." error
// NOTE: Custom Data Managers, Contributors and Authors CANNOT add media -- BUT Editors/Administrators can. Trying to add to {custom_post_type} post (for reasons unknown). Content for editor set to \'\'...
\'edit_files\' => true,
\'edit_others_pages\' => true,
\'edit_others_posts\' => true,
\'edit_pages\' => true,
\'edit_posts\' => true,
\'edit_private_pages\' => true,
\'edit_private_posts\' => true,
\'edit_published_pages\' => true,
\'edit_published_posts\' => true,
\'publish_pages\' => true,
\'publish_posts\' => true,
\'read_private_pages\' => true,
\'read_private_posts\' => true,
// ADDED: END
\'upload_files\' => true,
)
);
我知道我有点左撇子,但这感觉不太一致(即使很久以前的事情已经“修复”)。map_meta_cap 看起来它可能适用于这里,但没有自定义的帖子类型让我认为这是错误的解决方案。
理想情况下,我想知道为什么在整个过程中会对自定义帖子类型进行标记,但我坚持认为需要设置哪些权限/功能处理才能通过所见即所得编辑器上传?
编辑:因为我的角色是在插件激活期间设置的,所以我一定要停用并重新激活插件,以确保那里没有发生异常情况。