首页 > 解决方案 > WordPress 用户角色

问题描述

我们可以在 WordPress.org 中添加更多“用户角色”吗?就像我们已经有 User->change role to->student or subscriber or author or customer 等,换句话说,我想根据他们的研究领域添加subscriber1、subscriber2、subscriber3。提前致谢。

标签: wordpress

解决方案


是的,您可以在 wordpress 中添加自定义用户角色。在您的主题函数文件中添加此代码

add_role('subscriber1', __(
    'Moderator'),
    array(
        'read'              => true, // Allows a user to read
        'create_posts'      => true, // Allows user to create new posts
        'edit_posts'        => true, // Allows user to edit their own posts
        'edit_others_posts' => true, // Allows user to edit others posts too
        'publish_posts'     => true, // Allows the user to publish posts
        'manage_categories' => true, // Allows user to manage post categories
        )
);

推荐阅读