When non-admin users upload media, They get the following error:
Things i have checked:
- Wp-content/uploads and all sub folders have permission 755.
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.
- To my knowledge, users were able to upload images earlier last week. No change has been done in the code since then.
If anyone has had a similar issue, I'm open for suggestions. Thanks.
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