Created
November 13, 2018 10:22
-
-
Save nfsarmento/8e531eb38725bd8aa5ece2b3f3a79c13 to your computer and use it in GitHub Desktop.
WordPress restrict files bigger than 1mb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Restrict files bigger than 1mb to all users expect the ones inside of the array | |
* https://www.nuno-sarmento.com | |
*/ | |
add_filter( 'upload_size_limit', 'ns_change_upload_size' ); | |
function ns_change_upload_size(){ | |
/* setup an array of user ids to not be affected */ | |
$restrictupload = array( 1, 14, 17, 37, 14263, 14289 ); | |
/* check whether the current user id exists in the above array */ | |
if( !in_array( get_current_user_id(), $restrictupload ) ) { | |
return 1000 * 1024; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment