钩子文档

wp_hash_password_options

💡 云策文档标注

概述

wp_hash_password_options 是一个 WordPress 过滤器,用于修改传递给 password_hash() 和 password_needs_rehash() 函数的选项。它允许开发者自定义密码哈希算法的参数,默认算法为 bcrypt,但可通过其他过滤器更改。

关键要点

  • 过滤器名称:wp_hash_password_options
  • 作用:过滤传递给 password_hash() 和 password_needs_rehash() 的选项数组
  • 默认算法:bcrypt,可通过 'wp_hash_password_algorithm' 过滤器更改
  • 参数:$options(选项数组,默认为空数组)和 $algorithm(哈希算法,字符串或整数)
  • PHP 版本差异:算法常量值在 PHP 7.4+ 中为字符串,PHP 7.3 及更早版本中为整数
  • 相关函数:wp_password_needs_rehash() 和 wp_hash_password()
  • 引入版本:WordPress 6.8.0

注意事项

必须确保传递的选项与当前使用的算法兼容。


📄 原文内容

Filters the options passed to the password_hash() and password_needs_rehash() functions.

Description

The default hashing algorithm is bcrypt, but this can be changed via the ‘wp_hash_password_algorithm’ filter. You must ensure that the options are appropriate for the algorithm in use.

The values of the algorithm constants are strings in PHP 7.4+ and integers in PHP 7.3 and earlier.

Parameters

$optionsarray
Array of options to pass to the password hashing functions.
By default this is an empty array which means the default options will be used.
$algorithmstring|int
The hashing algorithm in use.

Source

$options = apply_filters( 'wp_hash_password_options', array(), $algorithm );

Changelog

Version Description
6.8.0 Introduced.