Skip to content

Instantly share code, notes, and snippets.

@purcebr
Last active July 22, 2016 14:32
Show Gist options
  • Save purcebr/30dc99ed0f8065f23c4086bffe310390 to your computer and use it in GitHub Desktop.
Save purcebr/30dc99ed0f8065f23c4086bffe310390 to your computer and use it in GitHub Desktop.
Allow Media MIME Type Uploads based on user role
add_filter('upload_mimes', 'admin_upload_svg');
function admin_upload_svg ( $existing_mimes=array() ) {
$user = wp_get_current_user();
// If the user is an admin, add the svg mimetype to the list.
if(in_array( 'administrator', (array) $user->roles )) {
$existing_mimes['svg'] = 'mime/type';
}
return $existing_mimes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment