钩子文档

show_password_fields

💡 云策文档标注

概述

show_password_fields 是一个 WordPress 过滤器,用于控制密码字段在用户编辑界面中的显示。它允许开发者根据条件动态决定是否展示密码输入框。

关键要点

  • 过滤器名称:show_password_fields
  • 参数:$show(布尔值,默认 true 表示显示密码字段)和 $profile_user(WP_User 对象,代表当前编辑的用户)
  • 应用场景:主要用于 user-edit.php 页面,自 WordPress 4.4.0 起仅在此处评估
  • 版本历史:引入于 1.5.1,2.8.0 添加 $profile_user 参数,4.4.0 限制评估范围

代码示例

$show_password_fields = apply_filters( 'show_password_fields', true, $profile_user );

📄 原文内容

Filters the display of the password fields.

Parameters

$showbool
Whether to show the password fields. Default true.
$profile_userWP_User
User object for the current user to edit.

Source

$show_password_fields = apply_filters( 'show_password_fields', true, $profile_user );

Changelog

Version Description
4.4.0 Now evaluated only in user-edit.php.
2.8.0 Added the $profile_user parameter.
1.5.1 Introduced.