remove_cap()删除一个用户角色的权限

目录

描述

Removes a capability from a role or specific user. Changing the capabilities of a role or user is persistent, meaning the removed capability will stay in effect until explicitly granted.

Note: This is not a global function, but a method of the WP_Roles, WP_Role and WP_User classes. It must be called using an instance of one of these classes, as shown in the examples.

Note: This setting is saved to the database (in table wp_options, field 'wp_user_roles'), so you should run this only once, on theme/plugin activation and/or deactivation.

remove_cap() 描述

用法

<?php 
  
global $wp_roles// global class wp-includes/capabilities.php
  
$wp_roles->remove_cap$role$cap ); 
?> 
or<?php
  $role 
get_role'author' );
  
$role->remove_cap$cap );
?> 

remove_cap() 用法

参数

$role

(string) (必填) role name

默认值: None

$cap

(string) (必填) capability name

默认值: None

remove_cap() 参数

注意

  • remove_cap() is not a global function, it is a method available from the classes WP_Roles, WP_Role and WP_User, so it must be called from an instance of one of these classes as shown in the above examples.

remove_cap() 注意

源文件

remove_cap() 函数的代码位于 wp-includes/capabilities.php.

remove_cap() 源文件

相关