• I used the following to block users from uploading videos:

    add_filter(‘upload_mimes’, ‘remove_mime_types’);
    function remove_mime_types($mimes) {
    unset($mimes[‘mp4’]);
    unset($mimes[‘wmv’]);
    unset($mimes[‘avi’]);
    }

    >>> but it blocked all types not just these. am i missing something ?
    or do you know any alternative way to block uploading videos?

Viewing 5 replies - 1 through 5 (of 5 total)
  • you seem to be missing:

    return $mimes;

    Thread Starter cleverschooling

    (@cleverschooling)

    i tried this:

    add_filter('upload_mimes', 'remove_mime_types');
    function remove_mime_types($mimes) {
        unset($mimes['mp4']);
        unset($mimes['wmv']);
        unset($mimes['avi']);
    	return $mimes;
    }

    it says error in second line, this one … function remove_mime_types($mimes) {

    am i still missing something ?

    • This reply was modified 3 years, 10 months ago by cleverschooling.
    • This reply was modified 3 years, 10 months ago by cleverschooling.
    • This reply was modified 3 years, 10 months ago by bcworkz. Reason: code fixed
    Thread Starter cleverschooling

    (@cleverschooling)

    i tried it in the code snippet plugin with few variation. when I add the
    return $mimes;
    all type are allowed
    and without the return $mimes;
    all files blocked !!!

    Moderator bcworkz

    (@bcworkz)

    There’s no error in the code you last posted. There could be an error in earlier code that is not noticed until the noted line. Or it could be a quirk of the snippets plugin. To prevent .mp4 uploads you need to unset $mimes['mp4|m4v'];

    When you post code in these forums, please use the code button or demarcate with backticks. Otherwise the forum’s parser corrupts your code, making it difficult to test or analyze for problems. I fixed the most recent code you posted so that I could properly test it.

    Thread Starter cleverschooling

    (@cleverschooling)

    @bcworkz
    Well, when i added the mp4|m4v it worked !!! but only mp4 it didnt work ???

    now how can remove other mimes ? all video , and audio type. Any official list that i can find on WordPress ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Removed few mime types but that blocked all types’ is closed to new replies.