钩子文档

invite_user

💡 云策文档标注

概述

invite_user 是一个 WordPress 动作钩子,在现有用户被邀请加入站点后、通知发送前触发。它允许开发者在邀请过程中执行自定义操作。

关键要点

  • 触发时机:在用户邀请完成但通知发送之前
  • 参数:$user_id(用户ID)、$role(角色信息数组)、$newuser_key(邀请密钥)
  • 用途:可用于日志记录、权限检查或自定义通知处理
  • 版本:从 WordPress 4.4.0 开始引入

代码示例

do_action( 'invite_user', $user_id, $role, $newuser_key );

📄 原文内容

Fires immediately after an existing user is invited to join the site, but before the notification is sent.

Parameters

$user_idint
The invited user’s ID.
$rolearray
Array containing role information for the invited user.
$newuser_keystring
The key of the invitation.

Source

do_action( 'invite_user', $user_id, $role, $newuser_key );

Changelog

Version Description
4.4.0 Introduced.