SO网友:Brooke.
你有几个选择。为您的帖子类型授予自定义权限或在现有权限内工作(如帖子)
在我看来,最好的办法是custom capability type 注册帖子类型时。在你的情况下,一个好的选择可能是“产品”
然后,您可以分配所需的功能。
// get the "author" role object
$role = get_role( \'designer\' );
// add "edit_products" to this role object
$role->add_cap( \'edit_products\' );
现在,如果您不想在自定义插件或函数中手动分配所有功能。php文件可以使用
Members Plugin 这是一个很棒的GUI。
如前所述,您还可以使用核心“edit\\u posts”,而不是分配新的能力类型,这取决于您对角色的限制程度。例如,如果允许他们编辑帖子和产品或仅编辑产品。
以下是《能力法典》中的图表:
[edit_post] => "edit_{$capability_type}"
[read_post] => "read_{$capability_type}"
[delete_post] => "delete_{$capability_type}"
[edit_posts] => "edit_{$capability_type}s"
[edit_others_posts] => "edit_others_{$capability_type}s"
[publish_posts] => "publish_{$capability_type}s"
[read_private_posts] => "read_private_{$capability_type}s"
[delete_posts] => "delete_{$capability_type}s"
[delete_private_posts] => "delete_private_{$capability_type}s"
[delete_published_posts] => "delete_published_{$capability_type}s"
[delete_others_posts] => "delete_others_{$capability_type}s"
[edit_private_posts] => "edit_private_{$capability_type}s"
[edit_published_posts] => "edit_published_{$capability_type}s