ACF form file upload not working for non-admin users

Viewed 29

I have an acf_form() on my website that includes some file upload fields. When I am logged in as admin, clicking the file upload button shows the wp media loader, when I am logged in as the custom role "user", I get the standard browser file upload and when the form is submitted, the file is not uploaded and does not appear in the media library.

Here is my acf_form() function:

acf_form(
    array(
        'id'                    => 'client-portal-acf-form',
        'post_id'               => 'new_post',
        'new_post'              => array(
            'post_type'         => 'technical_brief',
            'post_status'       => 'publish',
            'post_title'        => 'testing',
        ),
        'return'                => get_the_permalink(624) . '?bid=%post_id%',
        'submit_value'          => 'Upload your brief',
        'form_attributes'       => array(
            'enctype'           => 'multipart/form-data',
        ),
        'uploader'              => 'wp',
    )
);

and here is the user role declaration giving permissions:

add_role( 'user', __('User'),
    array(
        'read'              => true,
        'upload_files'      => true,
        'edit_posts'        => true,
        'edit_pages'        => true,
    )
);

Any suggestions for allowing file uploads for the User role?

Update:

It seems that the "user" role was part of the problem. I checked the capabilities of this role, and despite me adding capabilities, it only ever shows "read", so I guess this role is reserved by WP.

Another part of the issue seems to be the file types uploaded. PDF, DOC, DOCX, and ODT all work fine, but .txt and .rtf will not upload - the form submits, but the files do not appear in the back end. As such, the issue is not 100% solved, but is working enough that it is suitable for my project. I'll leave it as not answered for now in case any further knowledge shows up later that may help.

0 Answers
Related