Home / functions.php / Restrict file type uploads by user name
  • How to Restrict file type uploads by user name


    Adding this snippet to the functions.php of your worpress theme will let you restrict file uploads by type for specific users only. When a username is not in the users array they will only be able to upload jpg, and gif images.

    ( click code to copy )

    wordpress snippet : PHP

    function restrict_mime($mimes) {
        global $current_user;
        // change users in list
        $users = array(
        if (!in_array($current_user->user_login, $users)) {
    	$mimes = array(
    	                'jpg|jpeg|jpe' => 'image/jpeg',
    	                'gif' => 'image/gif',
    	return $mimes;

    ( WordPress codex functions, hooks, in this snippet. )

    upload_mimes, get_currentuserinfo, add_filter,