钩子文档

password_hint

💡 云策文档标注

概述

password_hint 是一个 WordPress 过滤器,用于修改描述站点密码复杂度策略的文本。开发者可以通过此 Hook 自定义密码提示信息,以增强用户体验或符合特定安全要求。

关键要点

  • password_hint 过滤器允许修改密码提示文本,参数为 $hint(字符串类型)。
  • 此过滤器在 wp_get_password_hint() 函数中被调用,用于生成强密码建议。
  • 从 WordPress 4.1.0 版本开始引入。

代码示例

add_filter( 'password_hint', 'change_password_hint_message' );
function change_password_hint_message( $hint ) {
    $hint = __( 'Hint: To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ & ).', 'text-domain' );
    return $hint;
}

📄 原文内容

Filters the text describing the site’s password complexity policy.

Parameters

$hintstring
The password hint text.

Source

return apply_filters( 'password_hint', $hint );

Changelog

Version Description
4.1.0 Introduced.

User Contributed Notes

  1. Skip to note 2 content

    /**
     * Change the wording of the password hint.
     *
     * @param string $hint
     * @return string
     */
    add_filter( 'password_hint', 'change_password_hint_message' );
    function change_password_hint_message( $hint ) {
        $hint = __( 'Hint: To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ & ).', 'text-domain' );
    
        return $hint;
    }