How to restrict allowed file types for user uploads?
-
Hello,
I am trying to restrict which file types can be uploaded by non-admin users. I have the following code in a mu-plugin, but it seemingly has no effect on which file types can be uploaded by users on their frontend WPUM account page (for example, I can still upload ‘.docx’ files):
add_filter('upload_mimes','jr_restrict_allowed_file_types'); /** * Define a custom list of allowed file types for user uploads. Exclude admins. * * @param array $mime_types Array of allowed file types. * @return array The (modified) array of file types. */ function jr_restrict_allowed_file_types($mime_types) { if (!current_user_can('administrator')) { $mime_types = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif', ); } return $mime_types; }
Is there any way to restrict which file types can be uploaded on the WPUM user account page?
Thanks. ??
/jenny
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to restrict allowed file types for user uploads?’ is closed to new replies.