How to limit video uploads to pro sites only?

I was wondering if there was a way to limit video uploads to higher level plans only. I see the network settings page allows me to limit upload file types but I only want to allow video extensions at paid pro-site levels. Any idea on how this can be accomplished?

  • Saurabh

    Hi @adam_fisher,

    Hope you are well today!

    Yes, it is possible to restrict uploads of file types, depending on levels:

    add_filter('upload_mimes','prosites_video_block',10);
    
    function prosites_video_block($mimes){
    
        global $blog_id;
    
        // if it just needs to be a paid site, otherwise specify a level
        $level = false;
    
        $is_pro = is_pro_site($blog_id,$level);
    
        if(!is_pro){
            $not_allowed = array(
                    'asf|asx' => 'video/x-ms-asf',
                    'wmv' => 'video/x-ms-wmv',
                    'wmx' => 'video/x-ms-wmx',
                    'wm' => 'video/x-ms-wm',
                    'avi' => 'video/avi',
                    'divx' => 'video/divx',
                    'flv' => 'video/x-flv',
                    'mov|qt' => 'video/quicktime',
                    'mpeg|mpg|mpe' => 'video/mpeg',
                    'mp4|m4v' => 'video/mp4',
                    'ogv' => 'video/ogg',
                    'webm' => 'video/webm',
                    'mkv' => 'video/x-matroska',
                    );
            return array_diff($mimes,$not_allowed);
        }
    
        return $mime;
    }

    Add the code above to your functions.php to disallow uploading video. You may need to edit the code depending on the levels you want to allow it for.

    Do let me know how it works for you.

    Best

    Saurabh