Method 1:
Remove the upload_files
capability from the respective roles.
e.g. removing it from author:
$role = get_role( 'author' );
$role->remove_cap( 'upload_files' );
This is saved to the database so it should only happen once, not on every page load. Removing it from the editor role should be the same albeit with the obvious modification. Removing the capability will have the desired effect, but it may have additional effects you may not find so desirable, the only way to be sure is to test
Method 2
Consider this code, which will make the upload error out if the user does not have admin privileges.
<?php
/**
* Plugin Name: Admin Only Uploads
* Description: Prevents Uploads from non-Admins
* Author: TJNowell
* Author URI: http://tomjn.com
* Version: 1.0
*/
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 can make use of this filter to be more specific than upload_file, e.g. preventing the upload of images, and only images, but allowing audio, etc
display: none;
and can access everything. – kaiser May 18 '14 at 15:11