capabilities - Remove upload file types filter for admin

Does anyone know if there is a function to removebypass file types uploads filter (specifically for admins). I know the

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 badges
Add a comment  | 

2 Answers 2

Reset to default 0

This 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

相关推荐

  • capabilities - Remove upload file types filter for admin

    Does anyone know if there is a function to removebypass file types uploads filter (specifically for admins). I know the

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信