add_cap()给指定的用户角色添加特定的权限

目录

描述

Adds a capability to a role or specific user. Changing the capabilities of a role or user is persistent, meaning the added capability will stay in effect until explicitly revoked.

N.B.: This setting is saved to the database (in table wp_options, field wp_user_roles), so it might be better to run this on theme/plugin activation

add_cap() 描述

参数

role (just with WP_Roles)

(string) (必填) role name

默认值: None

cap

(string) (必填) capability name

默认值: None

grant

(boolean) (可选) Whether the role is capable of performing this capability.

默认值: true

add_cap() 参数

返回值

void 

No return value

add_cap() 返回值

注意

There is no public function called add_cap() - just the class methods inside WP_Roles, WP_Role, WP_User that can add capabilities.

If you want to add a new role with capabilities, just add them when you add the role using add_role();.

add_cap() 注意

源文件

add_cap 函数的代码位于 wp-includes/capabilities.php.

add_cap() 源文件

相关