Skip to content

Instantly share code, notes, and snippets.

@nfsarmento
Created November 13, 2018 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfsarmento/8e531eb38725bd8aa5ece2b3f3a79c13 to your computer and use it in GitHub Desktop.
Save nfsarmento/8e531eb38725bd8aa5ece2b3f3a79c13 to your computer and use it in GitHub Desktop.
WordPress restrict files bigger than 1mb
/**
* 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