我有一个自定义的帖子类型,我们已经有几个月的时间了,并通过wordpress管理员用户进行管理。我们决定使用高级自定义字段插件来实现不同级别的“供应商”,并为其提供各种字段。
我在帖子类型中添加了下面的“功能”部分,这样我就可以使用“用户角色编辑器”插件管理功能,但是一旦添加了此代码,没有用户可以上传和附加文件,这就是我得到的错误:“抱歉,不允许您将文件附加到此帖子。”
我可以附加预上载的文件,也可以在删除功能代码时附加文件,但是我无法按角色管理功能。
此外,管理员用户不再能够编辑现有供应商条目。我认为我需要在主题函数文件中设置一些角色,但我不知道是哪些角色。我已经为相关用户角色启用了“上载文件”功能。
供应商注册代码如下:
function vendor() {
$labels = array(
\'name\' => _x( \'Vendors\', \'Post Type General Name\', \'vendor_text_domain\' ),
\'singular_name\' => _x( \'Vendor\', \'Post Type Singular Name\', \'vendor_text_domain\' ),
\'menu_name\' => __( \'Vendors\', \'vendor_text_domain\' ),
\'name_admin_bar\' => __( \'Vendors\', \'vendor_text_domain\' ),
\'archives\' => __( \'Vendor Archives\', \'vendor_text_domain\' ),
\'parent_item_colon\' => __( \'Parent Item:\', \'vendor_text_domain\' ),
\'all_items\' => __( \'All Vendors\', \'vendor_text_domain\' ),
\'add_new_item\' => __( \'Add New Vendor\', \'vendor_text_domain\' ),
\'add_new\' => __( \'Add New\', \'vendor_text_domain\' ),
\'new_item\' => __( \'New Vendor\', \'vendor_text_domain\' ),
\'edit_item\' => __( \'Edit Vendor\', \'vendor_text_domain\' ),
\'update_item\' => __( \'Update Vendor\', \'vendor_text_domain\' ),
\'view_item\' => __( \'View Vendor\', \'vendor_text_domain\' ),
\'search_items\' => __( \'Search Vendor\', \'vendor_text_domain\' ),
\'not_found\' => __( \'Not found\', \'vendor_text_domain\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\', \'vendor_text_domain\' ),
\'featured_image\' => __( \'Featured Image\', \'vendor_text_domain\' ),
\'set_featured_image\' => __( \'Set featured image\', \'vendor_text_domain\' ),
\'remove_featured_image\' => __( \'Remove featured image\', \'vendor_text_domain\' ),
\'use_featured_image\' => __( \'Use as featured image\', \'vendor_text_domain\' ),
\'insert_into_item\' => __( \'Insert into item\', \'vendor_text_domain\' ),
\'uploaded_to_this_item\' => __( \'Uploaded to this item\', \'vendor_text_domain\' ),
\'items_list\' => __( \'Vendor list\', \'vendor_text_domain\' ),
\'items_list_navigation\' => __( \'Vendor list navigation\', \'vendor_text_domain\' ),
\'filter_items_list\' => __( \'Filter items list\', \'vendor_text_domain\' ),
);
$args = array(
\'label\' => __( \'Vendor\', \'vendor_text_domain\' ),
\'description\' => __( \'Individual Vendors\', \'vendor_text_domain\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'revisions\', \'page-attributes\', ),
\'taxonomies\' => array( \'post_tag\' ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'menu_icon\' => \'dashicons-store\',
\'show_in_admin_bar\' => true,
\'show_in_nav_menus\' => true,
\'can_export\' => true,
\'upload_files\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'post\',
\'capabilities\' => array(
\'edit_post\' => \'edit_vendor\',
\'read_post\' => \'read_vendor\',
\'delete_post\' => \'delete_vendor\',
\'edit_posts\' => \'edit_vendors\',
\'edit_others_posts\' => \'edit_others_vendors\',
\'publish_posts\' => \'publish_vendors\',
\'read_private_posts\' => \'read_private_vendors\',
\'create_posts\' => \'create_vendor\',
\'upload_files\' => \'upload_vendor_files\'
),
);
register_post_type( \'vendor\', $args );
}