I’ve created a front-end form with acf_form()
( advanced custom field front-end form ) in woocommerce “view order” page which allows customers to upload some files for us , the form works fine for administrators but when you log-in with a customer account and you choose your file it says “you don’t have permission to attach files” , after some researches i edited "customer"
by adding below code to functions.php
:
/**
* Allow customers to upload files
*
* @package WordPress
* @subpackage Rightec Theme
* @author Dornaweb.com
*/
if ( current_user_can('customer') ) {
add_action('init', 'allow_customer_uploads', 20);
add_action('admin_init', 'allow_customer_uploads', 20);
}
function allow_customer_uploads() {
$customer = get_role('customer');
$customer->add_cap('upload_files');
$customer->add_cap('unfiltered_upload');
}
i as well tried "user role editor"
plugin , but it doesn’t work too
help me please!
I also had this problem trying to allow a new WooCommerce customer to upload files against an order. In addition to the permissions above, you need to:
'uploader' => 'basic'
in your acf_form() array.'edit_pages'
and'edit_posts'
to the customer role.You need ACF Pro to support the basic uploader, which you need because the WP Media uploader will never allow uploads from the frontend unless you’re an administrator.
Hope this helps someone!
I’m using ACF Pro 5.8.0 and i have add cap to author role with this function below and define ‘uploader’ => ‘basic’ or ‘uploader’ => ‘wp’ but author still can’t upload in frontend.
upload_files
was the only capability I needed to add in order to achieve this functionality. See @toni_lehtimaki comment in the first answer.Recently came across the same issue, found this post and now the solution. The required capabilities are
upload_files
in order to support the WP media uploader instead of the basic upload field and the capabilityedit_published_pages
is required in order to fix the permission restriction ‘You don’t have permission to attach files to this post.’Solution was easy. Give the user those capabilities: