Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

zh-cn:用户角色和权限

介绍

WordPress 使用角色的概念来让博客的所有者对用户进行权限控制。博客所有者可以控制用户写文章创建页面管理插件管理主题,以及管理其他用户的权限。博客所有者可以通过该工具分配用户权限。

WordPress 有五个预定义的角色: 管理员, 编辑, 作者, 投稿者订阅者。每一种角色被允许执行一系列被称作为功能的任务。 There are many Capabilities including publish_posts, moderate_comments, and edit_users. The default Capabilities are pre-assigned to each Role.

The Administrator Role is allowed to perform all possible Capabilities. Each of the other Roles has a decreasing number of allowed Capabilities. For instance, the Subscriber Role has just the read Capability. One particular Role should not be considered to be senior to another Role. Rather, consider that Roles define the user's responsibilities within the blog.

The WordPress Plugin API allows Roles and Capabilities to be added, removed and changed. Since Plugins might change Roles and Capabilities, just the default ones are addressed in this article.

角色摘要

  • Super Admin - Someone with access to the blog network administration features controlling the entire network (See Create a Network).
  • Administrator - Somebody who has access to all the administration features
  • Editor - Somebody who can publish and manage posts and pages as well as manage other users' posts, etc.
  • Author - Somebody who can publish and manage their own posts
  • Contributor - Somebody who can write and manage their posts but not publish them
  • Subscriber - Somebody who can only manage their profile

Upon installing WordPress, an Administrator account with all Capabilities is automatically created.

The default role for new users can be set from the Settings General SubPanel.

角色

A Role defines the set of tasks a user is allowed to perform. For instance, the role of Administrator encompasses every possible task that can be performed within a WordPress blog. On the other hand, the Author role allows the execution of just a small subset of tasks.

The following sections list the default Roles and their Capabilities:

3.0版的新特色

The documentation needs to be updated to incorporate Multisite, and super admin.

All these capabilities are exclusive to the administrator role.

3.1版的新特色

超级管理员

管理员

编辑

作者

投稿人

订阅者

权限—用户角色对应关系

权限 超级管理员 管理员 编辑 作者 投稿者 订阅者
管理_网络
管理_站点
管理_网络_用户
管理_网络_主题
管理_网络_选项
激活_插件
添加_用户
创建_用户
删除_插件
删除_主题
删除_用户
编辑_文件
编辑_插件
编辑_主题_选项
编辑_主题
编辑_用户
导出
导入
安装_插件
安装_主题
显示_用户
管理_选项
提升_用户
移除_用户
切换_主题
未滤过的_上传
更新_核心
更新_插件
更新_主题
编辑_控制板
节制_评论
管理_类别
管理_链接
未滤过的_html
编辑_他人的_posts
编辑_页面
编辑_他人的_页面
编辑_已发布_页面
发布_页面
删除_页面
删除_他人的_页面
删除_已发布_页面
删除_他人的_posts
删除_私有的_posts
编辑_私有的_posts
阅读_私有的_posts
删除_私有的_页面
编辑_私有的_页面
阅读_私有的_页面
编辑_已发布的_posts
上传_文件
发布_posts
删除_已发布_posts
编辑_posts
删除_posts
阅读

功能

切换主题

edit_themes

  • Since 2.0
  • Allows access to Appearance > Theme Editor to edit theme files.

edit_theme_options

install_themes

activate_plugins

edit_plugins

install_plugins

edit_users

edit_files

  • Since 2.0
  • Note: No longer used.

manage_options

  • Since 2.0
  • Allows access to Administration Panel options:
    • Settings > General
    • Settings > Writing
    • Settings > Reading
    • Settings > Discussion
    • Settings > Permalinks
    • Settings > Miscellaneous

moderate_comments

  • Since 2.0
  • Allows users to moderate comments from the Comments SubPanel (although a user needs the edit_posts Capability in order to access this)

manage_categories

manage_links

upload_files

import

unfiltered_html

  • Since 2.0
  • Allows user to post HTML markup or even JavaScript code in pages, posts, and comments.
  • Note: Enabling this option for untrusted users may result in their posting malicious or poorly formatted code.

edit_posts

  • Since 2.0
  • Allows access to Administration Panel options:
    • Posts
    • Posts > Add New
    • Comments
    • Comments > Awaiting Moderation

edit_others_posts

  • Since 2.0
  • Allows access to Administration Panel options:
    • Manage > Comments (Lets user delete and edit every comment, see edit_posts above)
  • user can edit other users' posts through function get_others_drafts()
  • user can see other users' images in inline-uploading [no? see inline-uploading.php]
  • See Exceptions

edit_published_posts

  • Since 2.0
  • User can edit their published posts. This capability is off by default.
  • The core checks the capability edit_posts, but on demand this check is changed to edit_published_posts.
  • If you don't want a user to be able edit his published posts, remove this capability. (see also this comment on the Role Manager Plugin Homepage).

publish_posts

  • Since 2.0
  • See and use the "publish" button when editing their post (otherwise they can only save drafts)
  • Can use XML-RPC to publish (otherwise they get a "Sorry, you can not post on this weblog or category.")

edit_pages

read

edit_others_pages

  • Since 2.1

edit_published_pages

  • Since 2.1

edit_published_pages

  • Since 2.1

delete_pages

  • Since 2.1

delete_others_pages

  • Since 2.1

delete_published_pages

  • Since 2.1

delete_posts

  • Since 2.1

delete_others_posts

  • Since 2.1

delete_published_posts

  • Since 2.1

delete_private_posts

  • Since 2.1

edit_private_posts

  • Since 2.1

read_private_posts

  • Since 2.1

delete_private_pages

  • Since 2.1

edit_private_pages

  • Since 2.1

read_private_pages

  • Since 2.1

delete_users

  • Since 2.1

create_users

  • Since 2.1

unfiltered_upload

  • Since 2.3

edit_dashboard

  • Since 2.5

update_plugins

  • Since 2.6

delete_plugins

  • Since 2.6

update_core

  • Since 3.0

list_users

  • Since 3.0

remove_users

  • Since 3.0

add_users

  • Since 3.0

promote_users

  • Since 3.0

delete_themes

  • Since 3.0

export

  • Since 3.0

edit_comment

  • Since 3.1

manage_network

  • Since 3.0
  • Multi-site only
  • Allows access to Super Admin menu
  • Allows user to upgrade network

manage_sites

  • Since 3.0
  • Multi-site only
  • Allows access to Network Sites menu
  • Allows user to add, edit, delete, archive, unarchive, activate, deactivate, spam and unspam new site/blog in the network

manage_network_users

manage_network_themes

manage_network_options

User Levels

Prior to version 2.0, WordPress used a user User Levels system. This was replaced in version 2.0 with the much improved and more extensible Roles and Capabilities system you see today. To maintain backwards compatibility with plugins that still use the user levels system (although this is very much discouraged), the default Roles in WordPress also include Capabilities that correspond to these levels. User Levels were finally deprecated in version 3.0.

Capability Administrator Editor Author Contributor Subscriber
level_10
level_9
level_8
level_7
level_6
level_5
level_4
level_3
level_2
level_1
level_0

User Level to Role Conversion

Change Log

  • 1.5: User Levels system was introduced.
  • 2.0: Roles and Capabilities system was introduced.
  • 3.0: User Levels system deprecated.

Resources

本文已被标记为未完成状态。您可以将其补充或翻译完整,以此帮助完善 Codex。