Enabling users to upload files

by Jon   Last Updated September 16, 2019 09:08 AM

I have a page template, where users can upload images. I use this piece of code for opening modal for media (js; only part of a code):

image_frame = wp.media({
  title: 'Select Media',
  multiple : 'add',
  button: {
    text: 'Use this media'

I have the following custom role:

add_role( 'customer',  __( 'Customer' ),
          'read'         => true,
          'edit_files'   => true,
          'upload_files'   => true,
          'read_post'   => true,
          'edit_post'   => true,
          'edit_others_post'   => true,

The custom post type also has

'upload_files' => true,

With this, users with the role of 'customer' can upload new files on the admin area. When they open the page template, a modal for media appears, and they can choose already uploaded image, but if Customers try to upload new image from the page template, they get the following message:

Sorry, you are not allowed to attach files to this post.

Any help or suggestions will be appreciated.


Related Questions

Editor User Role can't see other users media

Updated December 24, 2018 12:08 PM