I have a site with 1 admin, 11 editors, and 4000+ authors.  I need to prevent the authors from adding media to the server and using up all the storage.

Initially I tried 

    function removemediabuttons()
    {
    	if($user->wp_user_level >= 1) {
    		remove_action( 'media_buttons', 'media_buttons' );
    		global $menu;
    		unset($menu[10]);
    	}
    }
    add_action('admin_head','removemediabuttons');


This does remove the Add Media button for non-admins but the unset() approach to the admin sidebar menu had no effect and I assume that any author with a knowledge of WordPress could simply enter the media library URL and use it.

So I effectively eliminated this issue with 

`$wp_roles->remove_cap( 'author', 'upload_files' ); `

BUT this (correctly) removed the author role's access to use [WP User Avatar][1] and it is really important to users to not be forced to use Gravatar and to be able to change their avatars on a strictly local basis.

Is it possible to add_cap() just for the one module?

**UPDATE 2015-12-21**
Per bueltge's suggestion I changed code to check for profile in `get_current_screen()`.  This definitely enables the UI in the profile but when the uploads.php UI comes up for the upload it checks again and is denied. The check in this case is originating in /wp-admin/includes/ajax-actions.php so it is not the plugin itself doing the upload (and correctly so).

    global $wp_roles; 
    $wp_roles->remove_cap( 'author', 'upload_files' );
    add_action( 'current_screen', 'allowAvatarUploads' );
    
    function allowAvatarUploads() {
        $currentScreen = get_current_screen();
    	global $wp_roles; 
        if( $currentScreen->id === "profile" ) {
    		$wp_roles->add_cap( 'author', 'upload_files' );
    		// keep their menu consistent 
    		remove_menu_page('upload.php'); 
        } else {
    		
    	}
    }

  [1]: https://wordpress.org/plugins/wp-user-avatar/