grant_super_admin
云策文档标注
概述
grant_super_admin 是一个 WordPress 动作钩子,在用户被授予超级管理员权限之前触发。它允许开发者在权限授予前执行自定义代码。
关键要点
- 这是一个动作钩子,用于在用户获得超级管理员权限前执行操作。
- 钩子接收一个参数:$user_id,表示即将被授予权限的用户ID。
- 钩子由 grant_super_admin() 函数调用,位于 wp-includes/capabilities.php 文件中。
- 自 WordPress 3.0.0 版本引入。
代码示例
add_action( 'grant_super_admin', 'my_custom_function' );
function my_custom_function( $user_id ) {
// 在用户被授予超级管理员权限前执行的代码
// 例如:记录日志或发送通知
}
原文内容
Fires before the user is granted Super Admin privileges.
Parameters
$user_idint-
ID of the user that is about to be granted Super Admin privileges.
Source
do_action( 'grant_super_admin', $user_id );
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |