I’m looking to restrict all users (other than admins) to only be able to upload images e.g JPG’s and PNGs allowed for all users but still allow admins to upload pdfs etc. (Or even better would be to only prevent unregistered users from uploading anything other than JPGs and PNGs!)
I’ve been trying the following functions.php code but it still seems to restrict admins from uploading PDFs:
add_filter('upload_mimes','restict_mime');
function restict_mime($mimes) {
if(!current_user_can(‘administrator’)){
$mimes = array(
'jpg|jpeg|jpe' => 'image/jpeg',
'png' => 'image/png',
);
}
return $mimes;
}
Any ideas?