函数文档

rest_application_password_collect_status()

💡 云策文档标注

概述

rest_application_password_collect_status() 函数用于收集使用应用程序密码进行身份验证的状态,通过全局变量存储用户或错误信息以及 UUID。

关键要点

  • 函数接受两个参数:$user_or_error(必需,WP_Error 或用户实例)和 $app_password(可选,数组,默认空数组)。
  • 设置全局变量 $wp_rest_application_password_status 为 $user_or_error,并根据 $app_password['uuid'] 设置 $wp_rest_application_password_uuid。
  • 在 WordPress 5.6.0 中引入,5.7.0 版本添加了 $app_password 参数。

📄 原文内容

Collects the status of authenticating with an application password.

Parameters

$user_or_errorWP_Errorrequired
The authenticated user or error instance.
$app_passwordarrayoptional
The Application Password used to authenticate.

Default:array()

Source

function rest_application_password_collect_status( $user_or_error, $app_password = array() ) {
	global $wp_rest_application_password_status, $wp_rest_application_password_uuid;

	$wp_rest_application_password_status = $user_or_error;

	if ( empty( $app_password['uuid'] ) ) {
		$wp_rest_application_password_uuid = null;
	} else {
		$wp_rest_application_password_uuid = $app_password['uuid'];
	}
}

Changelog

Version Description
5.7.0 Added the $app_password parameter.
5.6.0 Introduced.