Enabling users to upload files


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.


, , Bojan 4 years 2019-09-16T03:38:34-05:00 0 Answers 87 views 0

Leave an answer