rest_application_password_check_errors

函数
rest_application_password_check_errors ( $result )
参数
  • (WP_Error|null|true) $result Error from another authentication handler, null if we should handle it, or another value if not.
    Required:
返回值
  • (WP_Error|null|true) WP_Error if the application password is invalid, the $result, otherwise true.
定义位置
相关方法
rest_application_password_collect_statusrest_add_application_passwords_to_indexrest_cookie_check_errorswp_is_application_passwords_available_for_userwp_is_application_passwords_supported
引入
5.6.0
弃用
-

rest_application_password_check_errors: 这个过滤钩子允许开发者修改在检查应用程序密码的有效性时返回的错误。

当使用基于应用密码的认证时,检查是否有错误。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function rest_application_password_check_errors( $result ) {
global $wp_rest_application_password_status;
if ( ! empty( $result ) ) {
return $result;
}
if ( is_wp_error( $wp_rest_application_password_status ) ) {
$data = $wp_rest_application_password_status->get_error_data();
if ( ! isset( $data['status'] ) ) {
$data['status'] = 401;
}
$wp_rest_application_password_status->add_data( $data );
return $wp_rest_application_password_status;
}
if ( $wp_rest_application_password_status instanceof WP_User ) {
return true;
}
return $result;
}
function rest_application_password_check_errors( $result ) { global $wp_rest_application_password_status; if ( ! empty( $result ) ) { return $result; } if ( is_wp_error( $wp_rest_application_password_status ) ) { $data = $wp_rest_application_password_status->get_error_data(); if ( ! isset( $data['status'] ) ) { $data['status'] = 401; } $wp_rest_application_password_status->add_data( $data ); return $wp_rest_application_password_status; } if ( $wp_rest_application_password_status instanceof WP_User ) { return true; } return $result; }
function rest_application_password_check_errors( $result ) {
	global $wp_rest_application_password_status;

	if ( ! empty( $result ) ) {
		return $result;
	}

	if ( is_wp_error( $wp_rest_application_password_status ) ) {
		$data = $wp_rest_application_password_status->get_error_data();

		if ( ! isset( $data['status'] ) ) {
			$data['status'] = 401;
		}

		$wp_rest_application_password_status->add_data( $data );

		return $wp_rest_application_password_status;
	}

	if ( $wp_rest_application_password_status instanceof WP_User ) {
		return true;
	}

	return $result;
}

常见问题

FAQs
查看更多 >