黄聪:wordpress前台自定义用户,调用wp_editor上传附件提示【抱歉,出于安全的考虑,不支持此文件类型】错误。

1、直接禁用文件类型检测,在wp-config.php文件中,添加这样一句代码define('ALLOW_UNFILTERED_UPLOADS', true);

2、在functions.php里面,添加下面代码(最重要是黄色背景那2句):

<?
    // 添加一个角色,允许地区编辑添加
    add_role('dq_edit','地区编辑', array(
        'level_3'      => true,
        'read'         => true,
        'edit_posts'   => true,
        'edit_published_posts' => true,
        'edit_others_posts'    => true,
        'publish_posts'   => true,
        'upload_files'   => true,  //允许上传文件
        'unfiltered_upload'   => true, //允许上传不安全的文件
    ));
    
    $role_object = get_role( 'dq_edit' );
    //为角色对象添加权限$cap
    $role_object->add_cap( 'edit_jihua' );
    $role_object->add_cap( 'upload_files' );
?>
原文地址:https://www.cnblogs.com/huangcong/p/4680574.html