我目前正在开发一个Wordpress商业目录插件,其中包含一个“商业”自定义帖子类型。我让它在激活时创建一个自定义的“business\\u author”用户角色,并为该角色分配特定功能,但它似乎限制了“Administrator”角色访问“business”自定义帖子类型。我曾尝试在插件激活时将这些功能添加到“管理员”角色,但似乎不起作用。
p、 我正在使用“map\\u meta\\u cap”过滤器为该帖子类型创建自定义功能。
下面的代码示例。。。
register_activation_hook( __FILE__, \'tis_business_activation\' );
register_deactivation_hook( __FILE__, \'tis_business_deactivation\' );
function tis_business_activation() {
add_role(\'business_author\', \'Business Listing Author\', array(
\'publish_businesses\' => false,
\'edit_businesses\' => true,
\'edit_others_busineses\' => false,
\'delete_businesses\' => true,
\'delete_others_businesess\' => false,
\'read_private_businesses\' => false,
\'edit_business\' => true,
\'delete_business\' => true,
\'read_business\' => true,
\'read\' => true,
\'upload_files\' => true
));
//Attempting to add above capabilities to administrator role.
$administrator = get_role(\'administrator\');
$administrator->add_cap(\'publish_business\');
$administrator->add_cap(\'edit_business\');
$administrator->add_cap(\'edit_others_businesses\');
$administrator->add_cap(\'delete_businesses\');
$administrator->add_cap(\'delete_others_businesses\');
$administrator->add_cap(\'read_private_businesses\');
$administrator->add_cap(\'edit_business\');
$administrator->add_cap(\'delete_business\');
$administrator->add_cap(\'read_business\');
}
function tis_business_deactivation() {
remove_role(\'business_author\');
global $wp_roles;
$wp_roles->remove_cap(\'administrator\', \'publish_business\');
$wp_roles->remove_cap(\'administrator\', \'edit_business\');
$wp_roles->remove_cap(\'administrator\', \'edit_others_businesses\');
$wp_roles->remove_cap(\'administrator\', \'delete_businesses\');
$wp_roles->remove_cap(\'administrator\', \'delete_others_businesses\');
$wp_roles->remove_cap(\'administrator\', \'read_private_businesses\');
$wp_roles->remove_cap(\'administrator\', \'edit_business\');
$wp_roles->remove_cap(\'administrator\', \'delete_business\');
$wp_roles->remove_cap(\'administrator\', \'read_business\');
}
任何帮助都会很神奇,我真的被这件事困住了。
抱歉,如果这已经得到了回答,我到处寻找答案,但找不到。