在WordPress中添加新角色


Adding New Role in WordPress

我通过以下代码在functions.php文件中添加了新角色:

// Add a custom user role
$result = add_role( 'supplier_for_planvent', __(
'Supplier_For_Planavent' ),

array(
    'read' => true, // true allows this capability
    'edit_posts' => true, // Allows user to edit their own posts
    'edit_pages' => true, // Allows user to edit pages
    'edit_others_posts' => true, // Allows user to edit others posts not just their own
    'create_posts' => true, // Allows user to create new posts
    'manage_categories' => true, // Allows user to manage post categories
    'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
));

但当我通过新的角色帐户登录时,我收到了这样的消息:

您没有足够的权限访问此页面。

有人能帮我吗?

我不喜欢将插件用于简单的事情,但我总是更喜欢将插件用作用户角色,因为有时这会变得非常棘手。尝试使用"用户角色编辑器"。