admin管理员组文章数量:1430588
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
本文标签: capabilitiesRemove upload file types filter for admin
版权声明:本文标题:capabilities - Remove upload file types filter for admin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745438610a2658342.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论