How to disable drag-and-drop upload function in Media Library?

Does any one knows a valid/standard way to disable drag and upload when accessing the media library in the admin area? In order to make this sense to you, I’m building a multisite and user of sub-site cannot upload media files but they can view.

I can remove their capability ‘upload_file‘ but that would completely remove the media experience.

So far this is what I’ve got:

function disable_drag_upload() {

    wp_deregister_script( 'wp-plupload' );

.. but that would skip the media library content.

Best Answer

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' );

You may Also Like:

Leave a Comment