- fixed password length validation;

- added settings for the password min/max length;
This commit is contained in:
Nikita Sinelnikov
2021-09-21 13:25:49 +03:00
parent 5394305340
commit e8c1497ec4
7 changed files with 45 additions and 11 deletions
+7 -2
View File
@@ -543,11 +543,16 @@ if ( ! class_exists( 'um\core\Password' ) ) {
if ( UM()->options()->get( 'reset_require_strongpass' ) ) {
if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) {
$min_length = UM()->options()->get( 'password_min_chars' );
$min_length = ! empty( $min_length ) ? $min_length : 8;
$max_length = UM()->options()->get( 'password_max_chars' );
$max_length = ! empty( $max_length ) ? $max_length : 30;
if ( mb_strlen( $args['user_password'] ) < $min_length ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least 8 characters', 'ultimate-member' ) );
}
if ( strlen( utf8_decode( $args['user_password'] ) ) > 30 ) {
if ( mb_strlen( $args['user_password'] ) > $max_length ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain less than 30 characters', 'ultimate-member' ) );
}
+7 -2
View File
@@ -82,11 +82,16 @@ function um_submit_account_errors_hook( $args ) {
}
if ( UM()->options()->get( 'account_require_strongpass' ) ) {
if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) {
$min_length = UM()->options()->get( 'password_min_chars' );
$min_length = ! empty( $min_length ) ? $min_length : 8;
$max_length = UM()->options()->get( 'password_max_chars' );
$max_length = ! empty( $max_length ) ? $max_length : 30;
if ( mb_strlen( $args['user_password'] ) < $min_length ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least 8 characters', 'ultimate-member' ) );
}
if ( strlen( utf8_decode( $args['user_password'] ) ) > 30 ) {
if ( mb_strlen( $args['user_password'] ) > $max_length ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain less than 30 characters', 'ultimate-member' ) );
}
+4 -4
View File
@@ -595,7 +595,7 @@ function um_submit_form_errors_hook_( $args ) {
}
if ( isset( $array['min_chars'] ) && $array['min_chars'] > 0 ) {
if ( $args[ $key ] && strlen( utf8_decode( $args[ $key ] ) ) < $array['min_chars'] ) {
if ( $args[ $key ] && mb_strlen( $args[ $key ] ) < $array['min_chars'] ) {
if ( empty( $array['label'] ) ) {
UM()->form()->add_error( $key, sprintf( __( 'This field must contain at least %s characters', 'ultimate-member' ), $array['min_chars'] ) );
} else {
@@ -605,7 +605,7 @@ function um_submit_form_errors_hook_( $args ) {
}
if ( isset( $array['max_chars'] ) && $array['max_chars'] > 0 ) {
if ( $args[ $key ] && strlen( utf8_decode( $args[ $key ] ) ) > $array['max_chars'] ) {
if ( $args[ $key ] && mb_strlen( $args[ $key ] ) > $array['max_chars'] ) {
if ( empty( $array['label'] ) ) {
UM()->form()->add_error( $key, sprintf( __( 'This field must contain less than %s characters', 'ultimate-member' ), $array['max_chars'] ) );
} else {
@@ -895,7 +895,7 @@ function um_submit_form_errors_hook_( $args ) {
$profile_show_bio = UM()->options()->get( 'profile_show_bio' );
if ( $profile_show_bio ) {
if ( strlen( utf8_decode( str_replace( array( "\r\n", "\n", "\r\t", "\t" ), ' ', $args['description'] ) ) ) > $max_chars && $max_chars ) {
if ( mb_strlen( str_replace( array( "\r\n", "\n", "\r\t", "\t" ), ' ', $args['description'] ) ) > $max_chars && $max_chars ) {
UM()->form()->add_error( 'description', sprintf( __( 'Your user description must contain less than %s characters', 'ultimate-member' ), $max_chars ) );
}
}
@@ -921,4 +921,4 @@ function um_invalid_nonce_redirect_url( $url ) {
return $url;
}
add_filter( 'um_login_invalid_nonce_redirect_url', 'um_invalid_nonce_redirect_url', 10, 1 );
add_filter( 'um_register_invalid_nonce_redirect_url', 'um_invalid_nonce_redirect_url', 10, 1 );
add_filter( 'um_register_invalid_nonce_redirect_url', 'um_invalid_nonce_redirect_url', 10, 1 );
+2 -2
View File
@@ -66,7 +66,7 @@ function um_dynamic_user_profile_title( $title, $id = '' ) {
return $title;
}
return ( strlen( $title ) !== strlen( utf8_decode( $title ) ) ) ? $title : utf8_encode( $title );
return ( strlen( $title ) !== mb_strlen( $title ) ) ? $title : utf8_encode( $title );
}
add_filter( 'the_title', 'um_dynamic_user_profile_title', 100000, 2 );
@@ -158,4 +158,4 @@ function um_change_profile_photo_label( $fields ) {
}
return $fields;
}
add_filter( 'um_predefined_fields_hook', 'um_change_profile_photo_label', 10, 1 );
add_filter( 'um_predefined_fields_hook', 'um_change_profile_photo_label', 10, 1 );