wp_revoke_user()
云策文档标注
概述
wp_revoke_user() 函数用于移除指定用户的所有能力(capabilities),通过 WP_User 对象的 remove_all_caps() 方法实现。
关键要点
- 函数接受一个必需的整数参数 $id,表示用户 ID。
- 内部将参数转换为整数,创建 WP_User 实例并调用 remove_all_caps() 方法。
- 该函数自 WordPress 2.1.0 版本引入。
代码示例
function wp_revoke_user( $id ) {
$id = (int) $id;
$user = new WP_User( $id );
$user->remove_all_caps();
}相关函数
- WP_User::__construct() - 构造函数,位于 wp-includes/class-wp-user.php。
原文内容
Remove all capabilities from user.
Parameters
$idintrequired-
User ID.
Source
function wp_revoke_user( $id ) {
$id = (int) $id;
$user = new WP_User( $id );
$user->remove_all_caps();
}
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |