钩子文档

username_exists

💡 云策文档标注

概述

username_exists 是一个 WordPress 过滤器,用于在检查用户名是否存在时进行干预。它允许开发者修改用户名存在性检查的结果。

关键要点

  • 这是一个过滤器 Hook,名称为 'username_exists',用于过滤用户名存在性检查的返回值。
  • 接受两个参数:$user_id(用户 ID 或 false)和 $username(要检查的用户名)。
  • 在 username_exists() 函数中被调用,用于确定给定用户名是否存在。
  • 从 WordPress 4.9.0 版本开始引入。

📄 原文内容

Filters whether the given username exists.

Parameters

$user_idint|false
The user ID associated with the username, or false if the username does not exist.
$usernamestring
The username to check for existence.

Source

return apply_filters( 'username_exists', $user_id, $username );

Changelog

Version Description
4.9.0 Introduced.