When uploading images from the frontend as a custom role (not an admin), the process fails.
This wasn't happening before, it only recently started happening. Are there any special permissions WPDT is missing or something so that uploading images as a custom role can work again?
As i mentioned there was no issue before. This is a recent issue.
By default, WordPress Media Library (used for attachments) allows file uploads only for users who have the upload_files capability. So, everyone who doesn’t have this capability (e.g. a subscriber) will receive an error on trying to upload a file.
To add this capability to subscribers you can e.g. use the User Role Editor plugin. Just enable the upload_files capability for the users who need it and it will work.
Another option is to add this capability dynamically via a hook. To do this you can add e.g. this code to your theme’s functions.php:
I'm making use of Ultimate Member and I can see that the user role I created using it already has that capability for upload_files, this all worked fine before, not sure why it stopped working.
I will try to do some debugging and downgrading of plugin versions to see if I can identify the reason.
When uploading images from the frontend as a custom role (not an admin), the process fails.
This wasn't happening before, it only recently started happening. Are there any special permissions WPDT is missing or something so that uploading images as a custom role can work again?
As i mentioned there was no issue before. This is a recent issue.
Attached files: Screenshot 2025-02-25 at 11.12.46 AM.png
Hello,
We will advise on this subject.
By default, WordPress Media Library (used for attachments) allows file uploads only for users who have the upload_files capability. So, everyone who doesn’t have this capability (e.g. a subscriber) will receive an error on trying to upload a file.
To add this capability to subscribers you can e.g. use the User Role Editor plugin. Just enable the upload_files capability for the users who need it and it will work.
Another option is to add this capability dynamically via a hook. To do this you can add e.g. this code to your theme’s functions.php:
Basically, it enables the upload_files capability to everyone – but you can extend this logic to allow it only for certain users at certain moments.
I hope it helps.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
I'm making use of Ultimate Member and I can see that the user role I created using it already has that capability for upload_files, this all worked fine before, not sure why it stopped working.
I will try to do some debugging and downgrading of plugin versions to see if I can identify the reason.