钩子文档

wp_create_application_password

💡 云策文档标注

概述

wp_create_application_password 是一个 WordPress 动作钩子,在创建应用程序密码时触发。它允许开发者在密码生成后执行自定义操作,例如记录或通知。

关键要点

  • 这是一个动作钩子,用于在应用程序密码创建时触发事件。
  • 钩子传递用户ID、密码详情、明文密码和创建参数等数据。
  • 参数包括 $user_id(用户ID)、$new_item(密码详情数组)、$new_password(明文密码)和 $args(创建参数数组)。
  • 与 WP_Application_Passwords::create_new_application_password() 函数相关,用于创建新密码。
  • 自 WordPress 5.6.0 引入,6.8.0 版本中哈希算法从 phpass 改为 wp_fast_hash()。

代码示例

do_action( 'wp_create_application_password', $user_id, $new_item, $new_password, $args );

📄 原文内容

Fires when an application password is created.

Parameters

$user_idint
The user ID.
$new_itemarray
The details about the created password.

  • uuid string
    The unique identifier for the application password.
  • app_id string
    A UUID provided by the application to uniquely identify it.
  • name string
    The name of the application password.
  • password string
    A one-way hash of the password.
  • created int
    Unix timestamp of when the password was created.
  • last_used null
    Null.
  • last_ip null
    Null.

$new_passwordstring
The generated application password in plain text.
$argsarray
Arguments used to create the application password.

  • name string
    The name of the application password.
  • app_id string
    A UUID provided by the application to uniquely identify it.

Source

do_action( 'wp_create_application_password', $user_id, $new_item, $new_password, $args );

Changelog

Version Description
6.8.0 The hashed password value now uses wp_fast_hash() instead of phpass.
5.6.0 Introduced.