Skip to content

Commit 963cc79

Browse files
committed
New password now not generated if another plugin registers a user using the 'password' field, along with filters to stop password generation.
1 parent 43b707e commit 963cc79

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

includes/functions.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,9 +1343,20 @@ function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
13431343
$password_set_by_admin = $_POST['pass1'];
13441344
}
13451345

1346+
$password = false;
13461347
if ( is_admin() && current_user_can( 'create_users' ) && $password_set_by_admin ) {
13471348
$password = sanitize_text_field( $password_set_by_admin );
1348-
} else {
1349+
}
1350+
1351+
if ( empty( $password ) && isset( $_POST['password'] ) ) {
1352+
$password = sanitize_text_field( $_POST['password'] );
1353+
}
1354+
1355+
if ( empty( $password ) ) {
1356+
$password = apply_filters( 'wpum_new_user_notification_password', $password, $user_id );
1357+
}
1358+
1359+
if ( empty( $password ) && apply_filters( 'wpum_new_user_notification_generate_password', true, $user_id ) ) {
13491360
$password = wp_generate_password( 24, true, true );
13501361
wp_set_password( $password, $user_id );
13511362
}

0 commit comments

Comments
 (0)