determine_current_user
云策文档标注
概述
determine_current_user 是一个 WordPress 过滤器钩子,用于在确定当前用户时进行干预。它允许开发者通过返回用户 ID 或 false 来影响当前用户的设置过程。
关键要点
- 这是一个过滤器钩子,用于在 WordPress 确定当前用户时进行自定义处理。
- 默认情况下,WordPress 使用此钩子从请求的 cookies 中确定当前用户。
- 返回 false 可以有效地短路设置当前用户的过程。
- 参数 $user_id 可以是整数(用户 ID)或 false(表示未确定用户)。
- 相关函数包括 _wp_get_current_user(),用于检索当前用户对象。
- 此钩子自 WordPress 3.9.0 版本引入。
原文内容
Filters the current user.
Description
The default filters use this to determine the current user from the request’s cookies, if available.
Returning a value of false will effectively short-circuit setting the current user.
Parameters
$user_idint|false-
User ID if one has been determined, false otherwise.
Source
$user_id = apply_filters( 'determine_current_user', false );
Changelog
| Version | Description |
|---|---|
| 3.9.0 | Introduced. |