Instead of removing upload script you can make the upload error out if the user does not have admin privileges. Like this-
function tomjn_only_upload_for_admin( $file ) {
if ( ! current_user_can( 'manage_options' ) ) {
$file['error'] = 'You can\'t upload images without admin privileges!';
}
return $file;
}
add_filter( 'wp_handle_upload_prefilter', 'tomjn_only_upload_for_admin' );
For other possible way please follow this answer- https://wordpress.stackexchange.com/a/105558/59760
Related Posts:
- How to Protect Uploads, if User is not Logged In?
- WordPress Uploads Folder can’t be Written to
- Restricting access to files within a specific folder [duplicate]
- Failed media import
- Change WordPress’ media upload URL?
- Organizing media uploads
- Moving existing media items to new upload path structure not updating full URL path
- Proper way to change the path of uploads folder for existing WordPress site
- Cannot upload anything via wordpress
- Rotating image does not work for custom image sizes
- Limit number of images to upload in wp.media function
- WordPress media upload automatic refresh
- Upload video in custom folder
- Set Maximum Width for an uploaded image
- Too slow Image upload in WordPress Media Library as image number increases
- Whats wrong with my wp gallery?
- How to Protect Uploads, if User is not Logged In?
- Handle image file and save it to media
- cant able to upload media to my wordpress blog
- Customize WordPress Upload Directory
- Another “Sent Headers” Error w/ Missing Temporary Folder
- How Can I Add the “Insert From URL” Tab to a Custom 3.5 Media Uploader?
- what happens to existing media files when I switch to year/month directory structure format?
- Decrease file size upload in Media
- WordPress Media Manager 3.5 – default link to
- Image upload callback in new 3.5 media
- “Add Media” only shows “Full Size” under Attachment Display Settings
- Differentiate Featured Image from Post Images upon Upload
- Any plugin out there that uses WP’s internal image uploader?
- There’s a way to scale media (images) at 50%?
- Failed to import media from a local wordpress site to a live one
- Media Uploader: get deleted files
- Rename “Add Media” Button To “Add Images”
- Filter what image sizes get generated
- Alter media caption/description conflict in WordPress?
- How to create an edit media button for slideshow plugin?
- Upload mobi and epub file in the MEDIA of WP
- WordPress Media mime type filter problem 4.0
- Setting higher upload limit
- Multisite media library uploads broken images
- Media is shown in listview but not in gridview whenever i activate my Custom Theme
- Uploading dwg files to wordpress
- Find unused images?
- Add instructions For Media Library Uploads
- Images not being generated at correct size
- Switch between tabs on “Insert Media” dialog
- WordPress Issue : The uploaded file could not be moved to wp-content/uploads/
- Error: Warning: strpos() in media.php
- Custom controller for video that is added from editor
- How to get media source of text editor in WordPress
- how to upload file to media library using link [closed]
- Removal of Media Gallery pictures
- How to allow logged out users to upload media?
- Media Library not showing images but still acknowledges existence
- RSS audio enclosures have length of zero (podcast duration is missing)
- Upload media only to DB
- Is it possible to import all files from a uploads DIR into WP media, retaining paths to the files
- How does WordPress decides how many sizes of an image to create?
- How to programatically toggle the media setting “Organize my uploads into month- and year-based folders”?
- Unable to add logo or header [closed]
- Big file upload give HTTP error
- Image upload to media library fails. Folder won’t create, database insert fail, XAMPP Windows
- Location of image metadata on my server
- Admin edit S3 Media file?
- Disable image rename on upload
- How to change archieve frequency of the media file in uploads folder for wordpress blog
- How can i identify media uploaded to my website that is not being used anywhere anymore?
- image URL changed in wordpress
- How to move an image in a plugin to the upload directory and make it as a media of wordpress?
- Specific folder and no thumbnail generation for media_sideload_image
- Import media (.xml) does not attribute featured images to posts
- WordPress append -1 to the image name
- Blog suddenly can’t display .jpg
- Pre-load images into a new users media gallery
- Modify Maximum upload file size text in WordPress Media
- Updated wordpress missing image upload area
- WP REST API Create media return Timeout Gateway in response, but media created
- Replicate Media Galley Edit view in Add Media View
- Front-End Upload media with category
- Creating multiple instances of Media Uploader
- Sanitizing existing media library paths and page links from foreign characters
- Change behavior of the “ADD Media” buttom
- Set default “Link CSS Class” in add media admin editor
- Disable wordpress gif compression?
- How could you allow users to upload a video in within their profile and display it on a wordpress site?
- wordpress doesnt add media.css file
- How to create different media uploader frames / filter library depending on a custom action
- How to share media between independent blogs?
- WP Capabilities to Add Media, Use Media, But Not Edit Them
- Is there a way to limit multi upload in media upload box?
- Limit attachment caption characters
- Extra metadata for media items
- Elegant way to signify inheritance and relationship between posts
- Media Player gone on front end
- Why does uploading a media file a second time restore older version?
- add file name column to media library to sort by
- Media Gallery doesn’t show (using WP-Read Only)
- Cache of site on browser
- Is it possible to restrict the number of media uploads (photos) per user?
- How To Convert External Image URLs To Own Website’s Uploaded Images Automatically?