错误您无权在此帖子中附加文件"在 Wordpress 上 [英] Error " You dont have permission to attach files to this post" on Wordpress

查看:35
本文介绍了错误您无权在此帖子中附加文件"在 Wordpress 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当非管理员用户上传媒体时,他们收到以下错误:

When non-admin users upload media, They get the following error:

我检查过的东西:

  1. Wp-content/uploads 和所有子文件夹的权限为 755.
  2. 测试用户(收到此错误的用户)的核心功能和自定义设置为 media_upload 的 yes请参考下图:

  1. Wp-content/uploads and all sub folders have permission 755.
  2. Core capabilities and custom for a test user ( who gets this error) is set for yes for media_upload Refer to the image below:

停用所有插件,问题依旧.

Deactivated all plugins, issue remains same.

如果有人遇到过类似的问题,我愿意提供建议.谢谢.

If anyone has had a similar issue, I'm open for suggestions. Thanks.

更新从 wp-admin/includes/ajax-action.php,我删除了以下部分:

UPDATE From wp-admin/includes/ ajax-action.php, I removed the following part:

if ( isset( $_REQUEST['post_id'] ) ) {
    $post_id = $_REQUEST['post_id'];
    if ( ! current_user_can( 'edit_post', $post_id ) ) {
        echo wp_json_encode( array(
            'success' => false,
            'data'    => array(
                'message'  => __( "You don't have permission to attach files     to this post." ),
                'filename' => $_FILES['async-upload']['name'],
            )
        ) );

        wp_die();
    }
    }

我意识到这只是一个查看用户能力的检查点,但我不完全理解为什么删除这部分有助于解决问题.现在测试用户可以成功上传媒体(媒体上传也成功了)并且没有权限错误并且底部的上传媒体"按钮不再是灰色的,所以我可以正常上传.谢谢

I realize that this is just sort of a checkpoint to see user capabilities but I dont fully understand why removing this part helped solve the issue. Now test user can upload media successfully ( media upload was successful earlier too) and there is no permission error and "UPLOAD MEDIA" button at the bottom is not greyed any more so I can upload as normal. Thanks

推荐答案

完全不建议删除核心 WP 代码!

Removing core WP code isn't recommended at all!

这种错误的原因通常是您的托管环境中的 PHP 上传限制.请参阅此处有关如何更改 PHP 值的示例:更改最大上传文件大小

The cause of this kind of error is often a PHP upload limit in your hosting environment. See here an example of how to change your PHP values : Change the maximum upload file size

但是查看帖子类型的功能屏幕截图,您的角色似乎甚至无法编辑帖子.我首先至少启用此功能:edit_posts.也许还有其他一些与职位相关的能力.

But looking at your capabilities screenshot for posts Post Type, it seems your Role doesn't even enable to edit a post. I would first at least enable this Capability : edit_posts. And maybe some other posts-related Capabitilies.

作为参考,这里有一个有助于理解 Wordress 角色和能力的有用表格:能力与能力对比.角色表

For reference, here is a useful table to help understand Wordress Roles and Capabilities : Capability vs. Role Table

这篇关于错误您无权在此帖子中附加文件"在 Wordpress 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆