Does anyone know if there is a function to remove/bypass file types uploads filter (specifically for admins). I know there are plugins available but they often break or don't contain ALL the mime types I need to allow and to be completely honest I'm just tired of dealing with this constantly. I also know about the constant ALLOW_UNFILTERED_UPLOADS which I'm using currently, but eventually I need only for the admin to be able to upload without restriction. I'm not sure how to do this in config file. Tried searching for a resolution but only found for allowing specific file types.
Does anyone know if there is a function to remove/bypass file types uploads filter (specifically for admins). I know there are plugins available but they often break or don't contain ALL the mime types I need to allow and to be completely honest I'm just tired of dealing with this constantly. I also know about the constant ALLOW_UNFILTERED_UPLOADS which I'm using currently, but eventually I need only for the admin to be able to upload without restriction. I'm not sure how to do this in config file. Tried searching for a resolution but only found for allowing specific file types.
Share Improve this question edited Jun 4, 2019 at 15:45 dkangy asked Jun 3, 2019 at 16:54 dkangydkangy 114 bronze badges2 Answers
Reset to default 0This is example for only doc file for admin.
You are also add another file to avoid restriction for admin.
add_filter( 'wp_check_filetype_and_ext', 'file_and_ext_allow_for_user', 10, 4 );
function file_and_ext_allow_for_user( $types, $file, $filename, $mimes )
{
if( is_admin() ){
if( false !== strpos( $filename, '.doc' ) )
{
$types['ext'] = 'doc';
$types['type'] = 'application/msword';
}
}
return $types;
}
Ok my mistake. I didn't realize setting ALLOW_UNFILTERED_UPLOADS=true ONLY applies to admins already. Which might explain why it was difficult to find an answer to my original question. Woops! Source: https://code.tutsplus/articles/new-wp-config-tweaks-you-probably-dont-know--wp-35396
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745438610a4627726.html
评论列表(0条)