钩子文档

pre_user_id

💡 云策文档标注

概述

pre_user_id 是一个 WordPress 过滤器,用于在设置评论作者的用户 ID 之前进行过滤。它主要用于兼容旧版本,优先检查 user_ID 参数。

关键要点

  • 过滤器名称:pre_user_id
  • 作用:过滤评论作者的用户 ID,在设置前应用
  • 参数:$user_id(整数类型),表示评论作者的用户 ID
  • 兼容性:首次评估时,会先检查 user_ID(向后兼容),然后检查标准的 user_id 值
  • 源代码示例:$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] );
  • 相关函数:wp_filter_comment(),用于过滤和清理评论数据
  • 引入版本:WordPress 1.5.0

📄 原文内容

Filters the comment author’s user ID before it is set.

Description

The first time this filter is evaluated, user_ID is checked (for back-compat), followed by the standard user_id value.

Parameters

$user_idint
The comment author’s user ID.

Source

$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] );

Changelog

Version Description
1.5.0 Introduced.