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:
- Cannot add multiple single images at once
- How to send custom variable in Media Uploader ajax request?
- wp_enqueue_media problem
- JavaScript implementation of Gzip
- Saving data-URI to media library
- Is there a JavaScript API? How to access public and private data in JS?
- Display attachments by ID in a wp.media frame
- Can I use the wp media uploader for my own plugin?
- Add tinymce buttons to caption textarea in media uploader
- How to HTML5 FormData Ajax
- Refresh wp.media after ajax call
- admin-ajax.php returns 0. How do I debug it and fix it?
- How to properly use wp.ajax.post?
- Custom PHP endpoint for a plugin’s AJAX call
- Refused to execute script from ‘***’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled
- WordPress Ajax Login without page reload
- WP3.5 Media Uploader – how to make it accept multiple images?
- Dynamically changing navigation links (next and previous) via AJAX
- Drag and drop multiple file upload using Ajax WordPress
- Vue.js + AJAX Shortcode
- Turn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)
- Retrieving JSON data in ajax request from media uploader
- ajax and nonce when JavaScript is in a seperate file
- admin-ajax.php HTTP400: BAD REQUEST – The request could not be processed by the server due to invalid syntax
- Restrict file types in the uploader of a wp.media frame
- AJAX issue – Uncaught SyntaxError when processing Zip File
- AJAX action not triggering PHP function
- WordPress AJAX Call Not Return Result
- How to allow to user non logged in WP system upload in media library?
- Nonces, AJAX, script variables & security in WordPress
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- How to localized one js file for different actions?
- wp-admin AJAX with Fetch API is done without user
- Using wp_handle_upload and media_handle_sideload with ajax
- Admin Ajax and HTML5 Formdata
- Trigger JS in custom meta box if a featured image is loaded/exists
- Call javascript function when category was added via ajax
- Populating content dynamically via AJAX and Advanced Custom Fields [closed]
- Help with AJAX front end comment moderation
- Woocommerce Ajax Add cart not working
- How to know what page is calling admin-ajax.php?
- How to set post_id to 0 when you upload image via Add media button. (async-upload.php)
- Ajax image upload with media_handle_upload and form.js
- Show Post Content with AJAX
- Switch between tabs on “Insert Media” dialog
- wp_handle_upload returns empty error array
- Load JavaScript from a post that’s loading into Fancybox via ajax
- Uppload image from another source wp.media
- Create a new post using rest api and save featured image using an external image url
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- Multiple media uploader buttons target only one input on the same page
- Performance optimization of tree like structure
- How do I query posts by a sub value with the API?
- Radio buttons live refresh in the customizer
- Gravity Forms closes my popup on Validation Error [closed]
- How do I Import / Upload Files with jQuery AJAX?
- wp_mail doesn’t work when logged in?
- While Ajax is working well, media upload isn’t showing the imagines
- javascript ajax and nonce
- How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?
- Making POST request with AJAX returns a 400 error (without jQuery)
- Is there a better way to access transients using javascript
- Run javascript upon successfully set featured image
- Distinguish between 2 instances of admin-ajax.php
- Replace link with form to pass variables to javascript / ajax
- Ajax page load without reload
- Get uploaded attachment width & height and attachment ID after upload them
- Why is the file not uploading to the server?
- Get localize of a loaded javascript
- Updating failed. The response is not a valid JSON response. specific to my browser when I include javascript in my html
- Uncaught TypeError: Cannot read properties of undefined (reading ‘message’) [closed]
- Refresh checkout fields on add to cart with order bump
- Refresh Gutenberg with JS for it show updated post
- javascript onClick update user_meta from jquery.ajax
- how to make sure js is enabled before executing php function
- How to Object.freeze wp_localize_script
- How to pass value from ajax to php in no conflict mode?
- ERROR while passing data from JS to PHP via AJAX
- Frontend AJAX Media Upload returning 404
- React to AJAX adding to the page
- Download doccument on server rather than clients browser
- Using existing ajax data that is loaded into page
- How to require files in a custom endpoint
- Ajax call from Plugin using Class
- How to safely pass post_id and user_id via AJAX to the backend (prevent user from changing it via JS)?
- AJAX form not working, still reloads on submit
- Get post details with pure javascript ajax
- Ajax WordPress pass post URLs
- Jquery wrap permalink in a data-attribute?
- Session variables lost during Ajax calls – WordPress – Sage Starter Theme
- ‘Dehighlighting’ navigation once clicked
- Bad Request when adding new post via ajax form
- AJAX admin Internal 500 error Failed to Upload
- Using Javascript Callback from plugin in a theme
- WordPress Ajax send response on every iteration of a loop
- Running js in html code with same content
- How to get current_user_id from wordpress in node js?
- AJAX call not initializing for non-admins in WordPress
- Escaping admin_url output being passed to js (esc_js vs esc_url)
- How to submit a button automatically after every scheduled hours?