automattic/jetpack-password-checker

Password Checker.

Package info

github.com/Automattic/jetpack-password-checker

Type:jetpack-library

pkg:composer/automattic/jetpack-password-checker

Statistics

Installs: 937 975

Dependents: 1

Suggesters: 0

Stars: 5

v0.4.14 2026-06-15 12:14 UTC

Requires

  • php: >=7.2

Requires (Dev)

Suggests

Provides

None

Conflicts

None

Replaces

None

GPL-2.0-or-later d1c1a7313f01936db73e1f4e70f4d80d83575ae5


README

Password Checker package.

Usage

Add a new test:

$tests = array(
	'preg_match' => array(
		'no_backslashes' => array(
			'pattern' => '/^[^\\\\]*$/u',
			'error' => __( 'Passwords may not contain the character "\".', 'jetpack' ),
			'required' => true,
			'fail_immediately' => true,
		),
	),
	'compare_to_list' => array(
		'not_a_common_password' => array(
			'list_callback' => 'get_common_passwords',
			'compare_callback' => 'negative_in_array',
			'error' => __( 'This is a very common password. Choose something that will be harder for others to guess.', 'jetpack' ),
			'required' => true,
		),
	)
);
$tests = apply_filters( 'password_checker_tests', $tests );

Test a password:

use Automattic\Jetpack\Password_Checker;

$user = new WP_User( 1 );
$password_checker = new Password_Checker( $user );
$password_checker->test( '123', true );

Using this package in your WordPress plugin

If you plan on using this package in your WordPress plugin, we would recommend that you use Jetpack Autoloader as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.

Security

Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.

License

jetpack-password-checker is licensed under GNU General Public License v2 (or later)