钩子文档

auth_cookie_bad_username

💡 云策文档标注

概述

auth_cookie_bad_username 是一个 WordPress 钩子,在用户认证过程中输入无效用户名时触发。它提供认证 cookie 的组件参数,供开发者处理错误情况。

关键要点

  • 触发时机:当用户认证时输入了无效用户名时触发此钩子。
  • 参数:$cookie_elements 是一个数组,包含 username、expiration、token、hmac、scheme 等 cookie 组件,但这些值来自客户端提供的 cookie,不应假设其有效性。
  • 用途:常用于自定义认证错误处理、日志记录或安全增强。
  • 相关函数:与 wp_validate_auth_cookie() 函数关联,用于验证认证 cookie。
  • 版本历史:自 WordPress 2.7.0 版本引入。

📄 原文内容

Fires if a bad username is entered in the user authentication process.

Parameters

$cookie_elementsstring[]
Authentication cookie components. None of the components should be assumed to be valid as they come directly from a client-provided cookie value.

  • username string
    User’s username.
  • expiration string
    The time the cookie expires as a UNIX timestamp.
  • token string
    User’s session token used.
  • hmac string
    The security hash for the cookie.
  • scheme string
    The cookie scheme to use.

Source

do_action( 'auth_cookie_bad_username', $cookie_elements );

Changelog

Version Description
2.7.0 Introduced.