Function
Validate the password of a new user.
tml_validate_new_user_password( WP_Error $errors = null )
Parameters
-
$errorsWP_Error Defaultnull - The registration errors.
Return
WP_Error
The registration errors.
Source
function tml_validate_new_user_password( $errors = null ) {
// phpcs:disable WordPress.Security.NonceVerification.Missing -- mirrors WP core's own registration password validation (register_new_user()), which has no nonce of its own.
if ( empty( $errors ) ) {
$errors = new WP_Error();
}
if ( tml_allow_user_passwords() ) {
if ( empty( $_POST['user_pass1'] ) || empty( $_POST['user_pass2'] ) ) {
$errors->add( 'empty_password', __( '<strong>Error:</strong> Please enter a password.', 'theme-my-login' ) );
} elseif ( false !== strpos( stripslashes( $_POST['user_pass1'] ), '\\' ) ) {
$errors->add( 'password_backslash', __( '<strong>Error:</strong> Passwords may not contain the character "\\".', 'theme-my-login' ) );
} elseif ( $_POST['user_pass1'] !== $_POST['user_pass2'] ) {
$errors->add( 'password_mismatch', __( '<strong>Error:</strong> Passwords don’t match. Please enter the same password in both password fields.', 'theme-my-login' ) );
}
}
// phpcs:enable WordPress.Security.NonceVerification.Missing
return $errors;
}
Uses
Used by
Changelog
| Version | Description |
|---|---|
| 7.0 | Introduced. |