如何在wordpress中添加上传文件的功能
问题描述:
我使用WordPress的付费主题。主题是关于汽车交易。在这个主题中有一个Role => Dealer
。如何在wordpress中添加上传文件的功能
当我作为经销商登录时,我可以编辑我的配置文件(但没有图像选项)。我的客户需要经销商公司徽标的上传字段。我创建了一个media up loader
及其工作,但并不完美。当我点击upload logo
按钮,媒体最多装载弹出,然后我选择一个图像,现在媒体最多装载机开始处理和一些小型秒就说明我这个错误:
我搜索有关的角色代码,我发现这个代码在父主题:
add_role('tdp_dealer', 'Vehicle Dealer', array(
'read' => true, // True allows that capability
'edit_dealer_fields' => true
));
然后我搜索上传能力,发现upload_files。我在代码中写了这个上限,但它不起作用。
add_role('tdp_dealer', 'Vehicle Dealer', array(
'read' => true, // True allows that capability
'edit_dealer_fields' => true,
'upload_files' => true,
'edit_posts' => true
));
然后我也试试这个代码,但它也没有工作:
function tdp_add_dealer_caps() {
// gets the author role
$role = get_role('tdp_dealer');
// This only works, because it accesses the class instance.
// would allow the author to edit others' posts for current theme only
//$role->add_cap('edit_dealer_fields', true);
$role->add_cap('upload_files', true);
}
add_action('init', 'tdp_add_dealer_caps');
所以,球员指导我,我怎么可以上传文件,图像为dealer user
。希望你能理解我的问题。
你问这个插件开发者,对吧?他们是最好的信息来源。 –