1

According to the Codex, all that's needed to enable the unfiltered_ upload capability - i.e. the ability to upload any filetypes to the Media Library rather than just the default whitelisted ones - is to set:

define( 'ALLOW_UNFILTERED_UPLOADS', true );

...in wp-config, which I have done and placed above the line where it says to stop editing.

Most online articles about enabling the capability suggest it's sufficient to stop here, including an answer on this very site, but the Codex itself suggests that it's necessary to actively assign the capability to users, which I've also done, in my theme's functions.php file:

$edit_admin = get_role('administrator');
$edit_admin->add_cap('unfiltered_upload');  

However, despite this, whenever going to my Media Library to upload a non-supported file (so far tested with an .AI file and .SVG file), I still get the standard error:

Sorry, this file type is not permitted for security reasons.

Why is this?

2
  • How are you calling the function the adds the capability? During what hook are you adding the capability? Aug 20 '19 at 22:08
  • @czerspalace There is no function. The code in this question is the only code I've added relating to unfiltered_upload, and the last two lines were taken from one of the few sources I could find at the time. I'm able to use those lines to add and remove other capabilities from roles without trouble. Unfiltered upload is the only one I'm having trouble with. Aug 20 '19 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.