PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.38
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.38
1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 All 173 releases
← All changes | includes/class-forms.php +140 -527 1.2.731.2.38 View file →
@@ -102,26 +102,27 @@
102 102 $processed = true;
103 103 }
104 104
105 105 if ( $processed ) {
106 +
106 107 if ( is_wp_error( $errors ) ) {
107 - aui()->alert(
108 - array(
109 - 'type' => 'error',
110 - 'content' => wp_kses_post( $errors->get_error_message() )
111 - ),
112 - true
113 - );
114 - } else if ( $redirect ) {
108 + echo aui()->alert(
109 + array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
110 + 'type' => 'error',
111 + 'class' => 'text-center',
112 + 'content' => wp_kses_post( $errors->get_error_message() ),
113 + )
114 + );
115 + } elseif ( $redirect ) {
115 116 wp_safe_redirect( $redirect );
116 117 exit();
117 - } else {
118 - aui()->alert(
119 - array(
120 - 'type' => 'success',
121 - 'content' => wp_kses_post( $message )
122 - ),
123 - true
118 + } else {
119 + echo aui()->alert(
120 + array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
121 + 'type' => 'success',
122 + 'class' => 'text-center',
123 + 'content' => wp_kses_post( $message ),
124 + )
124 125 );
125 126 }
126 127 }
127 128
@@ -195,9 +196,8 @@
195 196 * @since 1.0.0
196 197 */
197 198 public function process_image_crop( $data = array(), $type = 'avatar', $unlink_prev_img = false ) {
198 199 global $wpdb;
199 -
200 200 if ( ! is_user_logged_in() ) {
201 201 return false;
202 202 }
203 203
@@ -204,29 +204,8 @@
204 204 if ( empty( $_POST['uwp_crop_nonce'] ) || ! wp_verify_nonce( $_POST['uwp_crop_nonce'], 'uwp_crop_nonce_' . $type ) ) {
205 205 return;
206 206 }
207 207
208 - $image_url = ! empty( $data['uwp_crop'] ) ? esc_url( $data['uwp_crop'] ) : '';
209 -
210 - if ( empty( $image_url ) ) {
211 - return new WP_Error( 'empty_image', __( 'Upload valid image.', 'userswp' ) );
212 - }
213 -
214 - // Ensure we have a valid URL with an allowed meme type.
215 - $image_url = $this->normalize_url( $image_url );
216 -
217 - $content_url = str_replace( array( 'https://', 'http://' ) , '', untrailingslashit( WP_CONTENT_URL ) );
218 - $_image_url = str_replace( array( 'https://', 'http://' ), '', $image_url );
219 - if ( strpos( $_image_url, $content_url ) !== 0 ) {
220 - return new WP_Error( 'invalid_image', __( 'Invalid image url.', 'userswp' ) );
221 - }
222 -
223 - $filetype = wp_check_filetype( $image_url );
224 -
225 - if ( empty( $filetype['ext'] ) ) {
226 - return new WP_Error( 'invalid_image', __( 'Invalid image type.', 'userswp' ) );
227 - }
228 -
229 208 // If is current user's profile (profile.php)
230 209 if ( is_admin() && defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) {
231 210 $user_id = get_current_user_id();
232 211 // If is another user's profile page
@@ -236,8 +215,21 @@
236 215 } else {
237 216 $user_id = get_current_user_id();
238 217 }
239 218
219 + // Ensure we have a valid URL with an allowed meme type.
220 + $image_url = $this->normalize_url( esc_url( $data['uwp_crop'] ) );
221 + $filetype = wp_check_filetype( $image_url );
222 +
223 + $errors = new WP_Error();
224 + if ( empty( $image_url ) || empty( $filetype['ext'] ) ) {
225 + $errors->add( 'something_wrong', __( 'Something went wrong. Please contact site admin.', 'userswp' ) );
226 + }
227 +
228 + if ( $errors->has_errors() ) {
229 + return $errors;
230 + }
231 +
240 232 // Retrieve current thumbnail.
241 233 $current_field = 'avatar' === $type ? 'avatar_thumb' : 'banner_thumb';
242 234 $current_thumbnail = $this->normalize_url( uwp_get_usermeta( $user_id, $current_field, '' ) );
243 235 $thumb_postfix = '_uwp_' . $type . '_thumb';
@@ -260,14 +252,13 @@
260 252 $ext = $filetype['ext']; // to get extension
261 253 $name = sanitize_file_name( pathinfo( $image_path, PATHINFO_FILENAME ) ); //file name without extension
262 254 $thumb_image_name = $name . $thumb_postfix . '.' . $ext;
263 255 $thumb_image_location = str_replace( $name . '.' . $ext, $thumb_image_name, $image_path );
264 -
265 256 //Get the new coordinates to crop the image.
266 - $x = $data['uwpx'];
267 - $y = $data['uwpy'];
268 - $w = $data['uwpw'];
269 - $h = $data['uwph'];
257 + $x = $data['x'];
258 + $y = $data['y'];
259 + $w = $data['w'];
260 + $h = $data['h'];
270 261 //Scale the image based on cropped width setting
271 262 $scale = $full_width / $w;
272 263 //$scale = 1; // no scaling
273 264
@@ -327,11 +318,8 @@
327 318 *
328 319 */
329 320 public function normalize_url( $url ) {
330 321
331 - if ( empty( $url ) ) {
332 - return '';
333 - }
334 322 // Normalize.
335 323 $url = wp_normalize_path( $url );
336 324
337 325 // Remove query vars.
@@ -360,20 +348,22 @@
360 348 if ( ! is_user_logged_in() ) {
361 349 return false;
362 350 }
363 351
352 + if ( empty( $_POST['uwp_reset_nonce'] ) || ! wp_verify_nonce( $_POST['uwp_reset_nonce'], 'uwp_reset_nonce_' . $type ) ) {
353 + return;
354 + }
355 +
364 356 if ( is_admin() && defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) {
365 357 $user_id = get_current_user_id();
366 - } elseif ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) {
358 + // If is another user's profile page
359 + } elseif ( is_admin() && ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) {
367 360 $user_id = absint( $_GET['user_id'] );
361 + // Otherwise something is wrong.
368 362 } else {
369 363 $user_id = get_current_user_id();
370 364 }
371 365
372 - if ( empty( $_POST['uwp_reset_nonce'] ) || ! wp_verify_nonce( $_POST['uwp_reset_nonce'], 'uwp_reset_nonce_' . $type . '_' . $user_id ) ) {
373 - return;
374 - }
375 -
376 366 $errors = new WP_Error();
377 367 if ( empty( $user_id ) ) {
378 368 $errors->add( 'something_wrong', __( 'Something went wrong. Please try again.', 'userswp' ) );
379 369 }
@@ -477,10 +467,10 @@
477 467 }
478 468 } elseif ( ! empty( $notice ) ) {
479 469 echo wp_kses_post( $notice );
480 470 }
481 - }
482 - }
471 +}
472 +}
483 473
484 474 if ( $type == 'change' ) {
485 475 $user_id = get_current_user_id();
486 476 $password_nag = get_user_option( 'default_password_nag', $user_id );
@@ -533,15 +523,9 @@
533 523 if ( isset( $data['uwp_register_hp'] ) && '' != $data['uwp_register_hp'] ) {
534 524 wp_die( esc_html__( 'No spam please!', 'userswp' ) );
535 525 }
536 526
537 - $form_id = 1;
538 -
539 - if ( ! empty( $data['uwp_register_form_id'] ) ) {
540 - $form_id = (int) $data['uwp_register_form_id'];
541 - }
542 -
543 - if ( ! isset( $data['uwp_register_nonce'] ) || ! wp_verify_nonce( $data['uwp_register_nonce'], 'uwp-register-nonce-' . $form_id ) ) {
527 + if ( ! isset( $data['uwp_register_nonce'] ) || ! wp_verify_nonce( $data['uwp_register_nonce'], 'uwp-register-nonce' ) ) {
544 528 $message = aui()->alert(
545 529 array(
546 530 'type' => 'error',
547 531 'content' => __( 'Security verification failed. Try again.', 'userswp' ),
@@ -713,24 +697,8 @@
713 697 'last_name' => esc_attr( $last_name ),
714 698 'user_url' => esc_url_raw( $user_url ),
715 699 );
716 700
717 - // Set user role by form.
718 - $user_role = uwp_get_register_form_by( $form_id, 'user_role' );
719 -
720 - if ( ! empty( $user_role ) ) {
721 - $user_roles = uwp_get_user_roles();
722 - $chosen_role = strtolower( $user_role );
723 -
724 - if ( ! empty( $user_roles ) ) {
725 - $wp_roles = wp_roles();
726 -
727 - if ( $wp_roles->is_role( $chosen_role ) && in_array( $chosen_role, array_keys( $user_roles ) ) ) {
728 - $args['role'] = $chosen_role;
729 - }
730 - }
731 - }
732 -
733 701 $user_id = wp_insert_user( $args );
734 702
735 703 if ( is_wp_error( $user_id ) ) {
736 704 $message = aui()->alert(
@@ -749,13 +717,31 @@
749 717 }
750 718
751 719 $result = apply_filters( 'uwp_before_extra_fields_save', $result, 'register', $user_id );
752 720
753 - // Save user form id.
754 - if ( ! empty( $data['uwp_register_form_id'] ) ) {
721 + $form_id = 1;
722 +
723 + if ( isset( $data['uwp_register_form_id'] ) && ! empty( $data['uwp_register_form_id'] ) ) {
755 724 update_user_meta( $user_id, '_uwp_register_form_id', (int) $data['uwp_register_form_id'] );
725 + $form_id = (int) $data['uwp_register_form_id'];
756 726 }
757 727
728 + $user_role = uwp_get_register_form_by( $form_id, 'user_role' );
729 +
730 + if ( isset( $user_role ) && ! empty( $user_role ) ) {
731 + $user_roles = uwp_get_user_roles();
732 + $chosen_role = strtolower( $user_role );
733 + if ( ! empty( $user_roles ) ) {
734 + $wp_roles = wp_roles();
735 + if ( $wp_roles->is_role( $chosen_role ) && in_array( $chosen_role, array_keys( $user_roles ) ) ) {
736 + $new_user = get_userdata( $user_id );
737 + if ( $new_user ) {
738 + $new_user->set_role( $chosen_role );
739 + }
740 + }
741 + }
742 + }
743 +
758 744 $save_result = $this->save_user_extra_fields( $user_id, $result, 'register' );
759 745
760 746 $save_result = apply_filters( 'uwp_after_extra_fields_save', $save_result, $result, 'register', $user_id );
761 747
@@ -1175,11 +1161,8 @@
1175 1161 global $wp2fa;
1176 1162 if ( wp_doing_ajax() && isset( $wp2fa ) && ! empty( $wp2fa ) ) {
1177 1163 remove_action( 'wp_login', array( $wp2fa->login, 'wp_login' ), 20 );
1178 1164 }
1179 - if ( wp_doing_ajax() && class_exists( '\WP2FA\Authenticator\Login' ) ) {
1180 - remove_action( 'wp_login', array( 'WP2FA\Authenticator\Login', 'wp_login' ), 20 );
1181 - }
1182 1165
1183 1166 $user = wp_signon(
1184 1167 array(
1185 1168 'user_login' => $result['username'],
@@ -1188,14 +1171,10 @@
1188 1171 )
1189 1172 );
1190 1173
1191 1174 add_action( 'authenticate', 'gglcptch_login_check', 21, 1 );
1192 - if ( wp_doing_ajax() && class_exists( '\WP2FA\Authenticator\Login' ) ) {
1193 - add_action( 'wp_login', array( 'WP2FA\Authenticator\Login', 'wp_login' ), 20, 2 );
1194 - }
1195 1175
1196 - $wp2fa_available = ( isset( $wp2fa ) && ! empty( $wp2fa ) ) || class_exists( '\WP2FA\Authenticator\Login' );
1197 - if ( wp_doing_ajax() && ! is_wp_error( $user ) && $wp2fa_available ) {
1176 + if ( wp_doing_ajax() && ! is_wp_error( $user ) && isset( $wp2fa ) && ! empty( $wp2fa ) ) {
1198 1177
1199 1178 $two_fa = $this->check_2fa( $user );
1200 1179 if ( isset( $two_fa ) && ! empty( $two_fa ) ) {
1201 1180 if ( is_wp_error( $two_fa ) ) {
@@ -1216,20 +1195,8 @@
1216 1195 }
1217 1196 }
1218 1197 }
1219 1198
1220 - if ( wp_doing_ajax() && is_wp_error( $user ) && $this->wordfence_2fa_available() ) {
1221 - $wfls_2fa = $this->check_wordfence_2fa( $user, $result );
1222 - if ( ! empty( $wfls_2fa ) ) {
1223 - wp_send_json_success(
1224 - array(
1225 - 'html' => $wfls_2fa,
1226 - 'is_2fa' => true,
1227 - )
1228 - );
1229 - }
1230 - }
1231 -
1232 1199 if ( is_wp_error( $user ) ) {
1233 1200 $message = aui()->alert(
1234 1201 array(
1235 1202 'type' => 'error',
@@ -1297,12 +1264,9 @@
1297 1264
1298 1265 return $errors;
1299 1266 }
1300 1267
1301 - $provider = $this->get_wp2fa_provider_for_user( $user );
1302 - if ( empty( $provider ) ) {
1303 - return;
1304 - }
1268 + $provider = \WP2FA\Authenticator\Login::get_available_providers_for_user( $user );
1305 1269
1306 1270 ob_start();
1307 1271 ?>
1308 1272
@@ -1353,9 +1317,9 @@
1353 1317 echo aui()->input(
1354 1318 array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1355 1319 'type' => 'tel',
1356 1320 'id' => 'authcode',
1357 - 'name' => 'authcode',
1321 + 'name' => 'wp-2fa-email-code',
1358 1322 'placeholder' => esc_attr__( 'Verification Code', 'userswp' ),
1359 1323 'value' => '',
1360 1324 'label' => esc_html__( 'Verification Code', 'userswp' ),
1361 1325 'extra_attributes' => array(
@@ -1390,9 +1354,9 @@
1390 1354 </form>
1391 1355 </div>
1392 1356
1393 1357 <?php
1394 - $codes_remaining = $this->get_wp2fa_backup_codes_remaining( $user );
1358 + $codes_remaining = \WP2FA\Authenticator\Backup_Codes::codes_remaining_for_user( $user );
1395 1359 if ( isset( $codes_remaining ) && $codes_remaining > 0 ) {
1396 1360 ?>
1397 1361 <div class="uwp-2fa-methods-wrap" style="display:none;">
1398 1362 <form name="validate_2fa_backup_codes_form" id="validate_2fa_backup_codes_form"
@@ -1448,247 +1412,9 @@
1448 1412
1449 1413 return ob_get_clean();
1450 1414 }
1451 1415
1452 - /**
1453 - * Checks if the Wordfence Login Security module (2FA) is available.
1454 - *
1455 - * @since 1.2.5
1456 - * @package userswp
1457 - *
1458 - * @return bool
1459 - */
1460 - public function wordfence_2fa_available() {
1461 - return class_exists( '\WordfenceLS\Controller_Users' ) && class_exists( '\WordfenceLS\Controller_TOTP' );
1462 - }
1463 -
1464 - /**
1465 - * Checks whether Wordfence's 2FA requires a verification code for the
1466 - * failed login attempt and, if so, returns the markup for the code entry form.
1467 - *
1468 - * @since 1.2.5
1469 - * @package userswp
1470 - *
1471 - * @param WP_Error $error The error returned by wp_signon().
1472 - * @param array $result The validated login fields (username/password).
1473 - *
1474 - * @return string|void The 2FA form markup, or nothing if not applicable.
1475 - */
1476 - public function check_wordfence_2fa( $error, $result ) {
1477 - if ( 1 == uwp_get_option( 'disable_wordfence_2fa' ) ) {
1478 - return;
1479 - }
1480 -
1481 - if ( ! $this->wordfence_2fa_available() ) {
1482 - return;
1483 - }
1484 -
1485 - if ( ! is_wp_error( $error ) || 'wfls_twofactor_required' !== $error->get_error_code() ) {
1486 - return;
1487 - }
1488 -
1489 - $username = ! empty( $result['username'] ) ? $result['username'] : '';
1490 - if ( empty( $username ) ) {
1491 - return;
1492 - }
1493 -
1494 - $user = is_email( $username ) ? get_user_by( 'email', $username ) : get_user_by( 'login', $username );
1495 - if ( ! $user ) {
1496 - return;
1497 - }
1498 -
1499 - if ( ! \WordfenceLS\Controller_Users::shared()->has_2fa_active( $user ) ) {
1500 - return;
1501 - }
1502 -
1503 - if ( \WordfenceLS\Controller_Users::shared()->has_remembered_2fa( $user ) ) {
1504 - return;
1505 - }
1506 -
1507 - $login_nonce = wp_create_nonce( 'uwp-wfls-2fa-' . $user->ID );
1508 -
1509 - ob_start();
1510 - ?>
1511 -
1512 - <div class="uwp-2fa-methods-wrap">
1513 - <form name="validate_2fa_form" id="validate_2fa_form" class="validate_2fa_form" action="" method="post"
1514 - autocomplete="off">
1515 - <input type="hidden" name="provider" id="provider" value="wordfence"/>
1516 - <input type="hidden" name="uwp-auth-id" id="uwp-auth-id" value="<?php echo esc_attr( $user->ID ); ?>"/>
1517 - <input type="hidden" name="wp-auth-nonce" id="wp-auth-nonce"
1518 - value="<?php echo esc_attr( $login_nonce ); ?>"/>
1519 -
1520 - <p><?php esc_html_e( 'Please enter the authentication code from your two-factor authentication app, or a recovery code, to login:', 'userswp' ); ?></p>
1521 -
1522 - <?php
1523 - echo aui()->input(
1524 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1525 - 'type' => 'text',
1526 - 'id' => 'authcode',
1527 - 'name' => 'authcode',
1528 - 'placeholder' => esc_attr__( 'Authentication Code', 'userswp' ),
1529 - 'value' => '',
1530 - 'label' => esc_html__( 'Authentication Code', 'userswp' ),
1531 - 'extra_attributes' => array(
1532 - 'autocomplete' => 'one-time-code',
1533 - ),
1534 - )
1535 - );
1536 -
1537 - echo aui()->button(
1538 - array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1539 - 'type' => 'submit',
1540 - 'class' => 'btn btn-primary btn-block text-uppercase uwp-2fa-submit',
1541 - 'name' => 'submit',
1542 - 'icon' => '',
1543 - 'content' => esc_html__( 'Log In', 'userswp' ),
1544 - )
1545 - );
1546 - ?>
1547 - </form>
1548 - </div>
1549 -
1550 - <?php
1551 - return ob_get_clean();
1552 - }
1553 -
1554 - public function get_wp2fa_provider_for_user( $user ) {
1555 - if ( class_exists( '\WP2FA\Authenticator\Login' ) && method_exists( '\WP2FA\Authenticator\Login', 'get_available_providers_for_user' ) ) {
1556 - $provider = \WP2FA\Authenticator\Login::get_available_providers_for_user( $user );
1557 - if ( is_array( $provider ) ) {
1558 - $provider = key( $provider );
1559 - }
1560 -
1561 - return $provider;
1562 - }
1563 -
1564 - if ( class_exists( '\WP2FA\Admin\Helpers\User_Helper' ) && method_exists( '\WP2FA\Admin\Helpers\User_Helper', 'get_enabled_method_for_user' ) ) {
1565 - return \WP2FA\Admin\Helpers\User_Helper::get_enabled_method_for_user( $user );
1566 - }
1567 -
1568 - return '';
1569 - }
1570 -
1571 - public function get_wp2fa_backup_codes_remaining( $user ) {
1572 - if ( class_exists( '\WP2FA\Methods\Backup_Codes' ) && method_exists( '\WP2FA\Methods\Backup_Codes', 'codes_remaining_for_user' ) ) {
1573 - return \WP2FA\Methods\Backup_Codes::codes_remaining_for_user( $user );
1574 - }
1575 -
1576 - if ( class_exists( '\WP2FA\Authenticator\Backup_Codes' ) && method_exists( '\WP2FA\Authenticator\Backup_Codes', 'codes_remaining_for_user' ) ) {
1577 - return \WP2FA\Authenticator\Backup_Codes::codes_remaining_for_user( $user );
1578 - }
1579 -
1580 - return 0;
1581 - }
1582 -
1583 - public function validate_wp2fa_totp_authentication( $user ) {
1584 - if ( class_exists( '\WP2FA\Methods\TOTP' ) && method_exists( '\WP2FA\Methods\TOTP', 'validate_totp_authentication' ) ) {
1585 - return \WP2FA\Methods\TOTP::validate_totp_authentication( $user );
1586 - }
1587 -
1588 - if ( class_exists( '\WP2FA\Authenticator\Login' ) && method_exists( '\WP2FA\Authenticator\Login', 'validate_totp_authentication' ) ) {
1589 - return \WP2FA\Authenticator\Login::validate_totp_authentication( $user );
1590 - }
1591 -
1592 - return false;
1593 - }
1594 -
1595 - public function validate_wp2fa_email_authentication( $user ) {
1596 - if ( class_exists( '\WP2FA\Authenticator\Login' ) && method_exists( '\WP2FA\Authenticator\Login', 'validate_email_authentication' ) ) {
1597 - return \WP2FA\Authenticator\Login::validate_email_authentication( $user );
1598 - }
1599 -
1600 - if ( class_exists( '\WP2FA\Authenticator\Authentication' ) && method_exists( '\WP2FA\Authenticator\Authentication', 'validate_token' ) && isset( $_REQUEST['authcode'] ) ) {
1601 - return \WP2FA\Authenticator\Authentication::validate_token( $user, sanitize_text_field( wp_unslash( $_REQUEST['authcode'] ) ) );
1602 - }
1603 -
1604 - return false;
1605 - }
1606 -
1607 - public function validate_wp2fa_backup_codes( $user ) {
1608 - if ( class_exists( '\WP2FA\Methods\Backup_Codes' ) && method_exists( '\WP2FA\Methods\Backup_Codes', 'validate_backup_codes' ) ) {
1609 - return \WP2FA\Methods\Backup_Codes::validate_backup_codes( $user );
1610 - }
1611 -
1612 - if ( class_exists( '\WP2FA\Authenticator\Backup_Codes' ) && method_exists( '\WP2FA\Authenticator\Backup_Codes', 'validate_backup_codes' ) ) {
1613 - return \WP2FA\Authenticator\Backup_Codes::validate_backup_codes( $user );
1614 - }
1615 -
1616 - return false;
1617 - }
1618 -
1619 - /**
1620 - * Validates the Wordfence 2FA code submitted from the uwp-2fa form and,
1621 - * if valid, completes the login by setting the auth cookie.
1622 - *
1623 - * @since 1.2.5
1624 - * @package userswp
1625 - *
1626 - * @param WP_User $user The user attempting to complete 2FA login.
1627 - *
1628 - * @return void
1629 - */
1630 - public function process_login_wordfence_2fa( $user ) {
1631 - if ( ! $this->wordfence_2fa_available() ) {
1632 - $message = aui()->alert(
1633 - array(
1634 - 'type' => 'error',
1635 - 'content' => __( 'Invalid request! Please try again.', 'userswp' ),
1636 - )
1637 - );
1638 -
1639 - wp_send_json_error( array( 'message' => $message ) );
1640 - }
1641 -
1642 - $nonce = ( isset( $_POST['wp-auth-nonce'] ) ) ? sanitize_textarea_field( wp_unslash( $_POST['wp-auth-nonce'] ) ) : '';
1643 -
1644 - if ( ! wp_verify_nonce( $nonce, 'uwp-wfls-2fa-' . $user->ID ) ) {
1645 - $message = aui()->alert(
1646 - array(
1647 - 'type' => 'error',
1648 - 'content' => __( 'Invalid request! Please try again.', 'userswp' ),
1649 - )
1650 - );
1651 -
1652 - wp_send_json_error( array( 'message' => $message ) );
1653 - }
1654 -
1655 - $code = isset( $_POST['authcode'] ) ? sanitize_text_field( wp_unslash( $_POST['authcode'] ) ) : '';
1656 -
1657 - if ( empty( $code ) || true !== \WordfenceLS\Controller_TOTP::shared()->validate_2fa( $user, $code ) ) {
1658 - do_action( 'wp_login_failed', $user->user_login );
1659 -
1660 - $message = aui()->alert(
1661 - array(
1662 - 'type' => 'error',
1663 - 'content' => __( 'Invalid verification code.', 'userswp' ),
1664 - )
1665 - );
1666 -
1667 - wp_send_json_error( array( 'message' => $message ) );
1668 - }
1669 -
1670 - $remember = ( isset( $_REQUEST['rememberme'] ) ) ? filter_var( $_REQUEST['rememberme'], FILTER_VALIDATE_BOOLEAN ) : false;
1671 -
1672 - // Complete the login the same way wp_signon() would have, now that 2FA has been verified.
1673 - wp_set_auth_cookie( $user->ID, $remember );
1674 - wp_set_current_user( $user->ID );
1675 -
1676 - do_action( 'wp_login', $user->user_login, $user );
1677 -
1678 - $message = aui()->alert(
1679 - array(
1680 - 'type' => 'success',
1681 - 'content' => __( 'Validation successful. Redirecting...', 'userswp' ),
1682 - )
1683 - );
1684 -
1685 - wp_send_json_success( array( 'message' => $message ) );
1686 - }
1687 -
1688 1416 public function process_login_2fa() {
1689 - global $wp2fa;
1690 -
1691 1417 if ( ! isset( $_POST['uwp-auth-id'], $_POST['wp-auth-nonce'] ) ) {
1692 1418 return;
1693 1419 }
1694 1420
@@ -1693,70 +1419,46 @@
1693 1419 }
1694 1420
1695 1421 $auth_id = (int) $_POST['uwp-auth-id'];
1696 1422 $user = get_userdata( $auth_id );
1697 -
1698 1423 if ( ! $user ) {
1699 1424 $message = aui()->alert(
1700 - array(
1425 + array(
1701 1426 'type' => 'error',
1702 1427 'content' => __( 'Invalid user data. Please try again.', 'userswp' ),
1703 - )
1428 + )
1704 1429 );
1705 1430
1706 1431 wp_send_json_error( array( 'message' => $message ) );
1707 1432 }
1708 1433
1709 - if ( isset( $_POST['provider'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1710 - $provider = sanitize_textarea_field( wp_unslash( $_POST['provider'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1711 - } else {
1712 - $provider = '';
1713 - }
1434 + global $wp2fa;
1714 1435
1715 - if ( 'wordfence' === $provider ) {
1716 - $this->process_login_wordfence_2fa( $user );
1717 -
1718 - return;
1719 - }
1720 -
1721 1436 $nonce = ( isset( $_POST['wp-auth-nonce'] ) ) ? sanitize_textarea_field( wp_unslash( $_POST['wp-auth-nonce'] ) ) : '';
1437 + if ( true !== \WP2FA\Authenticator\Login::verify_login_nonce( $user->ID, $nonce ) ) {
1722 1438
1723 - if ( true !== \WP2FA\Authenticator\Login::verify_login_nonce( $user->ID, $nonce ) ) {
1724 1439 $message = aui()->alert(
1725 - array(
1440 + array(
1726 1441 'type' => 'error',
1727 1442 'content' => __( 'Invalid request! Please try again.', 'userswp' ),
1728 - )
1443 + )
1729 1444 );
1730 1445
1731 1446 wp_send_json_error( array( 'message' => $message ) );
1732 1447 }
1733 1448
1734 - $error = '';
1735 -
1736 - try {
1737 - $is_enabled = \WP2FA\Admin\Controllers\Settings::is_provider_enabled_for_role( \WP2FA\Admin\Helpers\User_Helper::get_user_role( $user ), $provider );
1738 -
1739 - if ( ! $is_enabled ) {
1740 - $error = __( 'Invalid 2FA provider for user.', 'userswp' );
1449 + if ( isset( $_POST['provider'] ) ) {
1450 + $provider = sanitize_textarea_field( wp_unslash( $_POST['provider'] ) );
1451 + $providers = \WP2FA\Authenticator\Login::get_available_providers_for_user( $user );
1452 + if ( isset( $providers[ $provider ] ) ) {
1453 + $provider = $providers[ $provider ];
1454 + } elseif ( isset( $provider ) ) {
1455 + $provider = $provider;
1456 + } else {
1457 + $provider = $provider;
1741 1458 }
1742 - } catch ( \Exception $e ) {
1743 - $error = $e->getMessage();
1744 1459 }
1745 1460
1746 - if ( $error ) {
1747 - do_action( 'wp_login_failed', $user->user_login );
1748 -
1749 - $message = aui()->alert(
1750 - array(
1751 - 'type' => 'error',
1752 - 'content' => $error
1753 - )
1754 - );
1755 -
1756 - wp_send_json_error( array( 'message' => $message ) );
1757 - }
1758 -
1759 1461 // If this is an email login, or if the user failed validation previously, lets send the code to the user.
1760 1462 if ( 'email' === $provider && true !== \WP2FA\Authenticator\Login::pre_process_email_authentication( $user ) ) {
1761 1463
1762 1464 }
@@ -1761,16 +1463,17 @@
1761 1463
1762 1464 }
1763 1465
1764 1466 // Validate TOTP.
1765 - if ( 'totp' === $provider && true !== $this->validate_wp2fa_totp_authentication( $user ) ) {
1467 + if ( 'totp' === $provider && true !== \WP2FA\Authenticator\Login::validate_totp_authentication( $user ) ) {
1468 +
1766 1469 do_action( 'wp_login_failed', $user->user_login );
1767 1470
1768 1471 $message = aui()->alert(
1769 - array(
1472 + array(
1770 1473 'type' => 'error',
1771 1474 'content' => __( 'Invalid verification code.', 'userswp' ),
1772 - )
1475 + )
1773 1476 );
1774 1477
1775 1478 wp_send_json_error( array( 'message' => $message ) );
1776 1479 }
@@ -1775,26 +1478,27 @@
1775 1478 wp_send_json_error( array( 'message' => $message ) );
1776 1479 }
1777 1480
1778 1481 // Validate Email.
1779 - if ( 'email' === $provider && true !== $this->validate_wp2fa_email_authentication( $user ) ) {
1482 + if ( 'email' === $provider && true !== \WP2FA\Authenticator\Login::validate_email_authentication( $user ) ) {
1483 +
1780 1484 do_action( 'wp_login_failed', $user->user_login );
1781 1485
1782 1486 if ( isset( $_REQUEST['wp-2fa-email-code-resend'] ) && 1 == $_REQUEST['wp-2fa-email-code-resend'] ) {
1783 1487 $message = aui()->alert(
1784 - array(
1488 + array(
1785 1489 'type' => 'info',
1786 1490 'content' => __( 'A new code has been sent.', 'userswp' ),
1787 - )
1491 + )
1788 1492 );
1789 1493
1790 1494 wp_send_json_error( array( 'message' => $message ) );
1791 1495 } else {
1792 1496 $message = aui()->alert(
1793 - array(
1497 + array(
1794 1498 'type' => 'error',
1795 1499 'content' => __( 'Invalid verification code.', 'userswp' ),
1796 - )
1500 + )
1797 1501 );
1798 1502
1799 1503 wp_send_json_error( array( 'message' => $message ) );
1800 1504 }
@@ -1800,16 +1504,17 @@
1800 1504 }
1801 1505 }
1802 1506
1803 1507 // Backup Codes.
1804 - if ( 'backup_codes' === $provider && true !== $this->validate_wp2fa_backup_codes( $user ) ) {
1508 + if ( 'backup_codes' === $provider && true !== \WP2FA\Authenticator\Login::validate_backup_codes( $user ) ) {
1509 +
1805 1510 do_action( 'wp_login_failed', $user->user_login );
1806 1511
1807 1512 $message = aui()->alert(
1808 - array(
1513 + array(
1809 1514 'type' => 'error',
1810 1515 'content' => __( 'Invalid backup code.', 'userswp' ),
1811 - )
1516 + )
1812 1517 );
1813 1518
1814 1519 wp_send_json_error( array( 'message' => $message ) );
1815 1520 }
@@ -1817,9 +1522,8 @@
1817 1522 \WP2FA\Authenticator\Login::delete_login_nonce( $user->ID );
1818 1523
1819 1524 $rememberme = false;
1820 1525 $remember = ( isset( $_REQUEST['rememberme'] ) ) ? filter_var( $_REQUEST['rememberme'], FILTER_VALIDATE_BOOLEAN ) : '';
1821 -
1822 1526 if ( ! empty( $remember ) ) {
1823 1527 $rememberme = true;
1824 1528 }
1825 1529
@@ -1826,17 +1530,13 @@
1826 1530 wp_set_auth_cookie( $user->ID, $rememberme );
1827 1531
1828 1532 do_action( 'two_factor_user_authenticated', $user );
1829 1533
1830 - if ( defined( 'WP_2FA_PREFIX' ) ) {
1831 - do_action( WP_2FA_PREFIX . 'user_authenticated', $user );
1832 - }
1833 -
1834 1534 $message = aui()->alert(
1835 - array(
1535 + array(
1836 1536 'type' => 'success',
1837 1537 'content' => __( 'Validation successful. Redirecting...', 'userswp' ),
1838 - )
1538 + )
1839 1539 );
1840 1540
1841 1541 wp_send_json_success( array( 'message' => $message ) );
1842 1542 }
@@ -1933,12 +1633,9 @@
1933 1633 }
1934 1634
1935 1635 do_action( 'uwp_after_validate', $result, 'forgot', $data );
1936 1636
1937 - $login_or_email = trim( $data['email'] );
1938 - $user_data = is_email( $login_or_email )
1939 - ? get_user_by( 'email', $login_or_email )
1940 - : get_user_by( 'login', $login_or_email );
1637 + $user_data = get_user_by( 'email', $data['email'] );
1941 1638
1942 1639 // if no user we fake it and bail
1943 1640 if ( ! $user_data ) {
1944 1641 $args = apply_filters(
@@ -1944,9 +1641,9 @@
1944 1641 $args = apply_filters(
1945 1642 'uwp_forgot_error_message',
1946 1643 array(
1947 1644 'type' => 'error',
1948 - 'content' => __( 'Invalid username/email or user doesn\'t exist.', 'userswp' ),
1645 + 'content' => __( 'Invalid email or user doesn\'t exists.', 'userswp' ),
1949 1646 )
1950 1647 );
1951 1648
1952 1649 $message = aui()->alert( $args );
@@ -1961,21 +1658,12 @@
1961 1658
1962 1659 // make sure user account is active before account reset
1963 1660 $mod_value = get_user_meta( $user_data->ID, 'uwp_mod', true );
1964 1661 if ( $mod_value == 'email_unconfirmed' ) {
1965 - $resend_link = uwp_get_forgot_page_url();
1966 - $resend_link = add_query_arg(
1967 - array(
1968 - 'user_id' => $user_data->ID,
1969 - 'action' => 'uwp_resend',
1970 - '_nonce' => wp_create_nonce('uwp_resend'),
1971 - ),
1972 - $resend_link
1973 - );
1974 1662 $message = aui()->alert(
1975 1663 array(
1976 1664 'type' => 'error',
1977 - 'content' => sprintf(__('Your account is not activated yet. Please activate your account first. <a href="%s">Resend</a>.', 'userswp'), $resend_link),
1665 + 'content' => __( 'Your account is not activated yet. Please activate your account first.', 'userswp' ),
1978 1666 )
1979 1667 );
1980 1668 if ( wp_doing_ajax() ) {
1981 1669 wp_send_json_error( $message );
@@ -1980,8 +1668,9 @@
1980 1668 if ( wp_doing_ajax() ) {
1981 1669 wp_send_json_error( $message );
1982 1670 } else {
1983 1671 $uwp_notices[] = array( 'forgot' => $message );
1672 +
1984 1673 return;
1985 1674 }
1986 1675 }
1987 1676
@@ -1996,8 +1685,9 @@
1996 1685 }
1997 1686
1998 1687 $as_password = apply_filters( 'uwp_forgot_message_as_password', false );
1999 1688
1689 + global $wpdb, $wp_hasher;
2000 1690 $reset_link = '';
2001 1691
2002 1692 if ( $as_password ) {
2003 1693 $new_pass = wp_generate_password( 12, false );
@@ -2009,21 +1699,17 @@
2009 1699 $message .= '<p>' . sprintf( __( 'Username: %s', 'userswp' ), $user_data->user_login ) . '</p>';
2010 1700 $message .= '<p>' . sprintf( __( 'Password: %s', 'userswp' ), $new_pass ) . '</p>';
2011 1701
2012 1702 } else {
2013 - // Use WordPress core to generate, hash (wp_fast_hash in WP 6.8+), and store the reset key.
2014 - // This ensures compatibility with check_password_reset_key() on all WP versions.
2015 - $key = get_password_reset_key( $user_data );
1703 + $key = wp_generate_password( 20, false );
1704 + do_action( 'retrieve_password_key', $user_data->user_login, $key );
2016 1705
2017 - if ( is_wp_error( $key ) ) {
2018 - if ( wp_doing_ajax() ) {
2019 - wp_send_json_error( $key->get_error_message() );
2020 - } else {
2021 - $uwp_notices[] = array( 'forgot' => aui()->alert( array( 'type' => 'error', 'content' => $key->get_error_message() ) ) );
2022 - return;
2023 - }
1706 + if ( empty( $wp_hasher ) ) {
1707 + require_once ABSPATH . 'wp-includes/class-phpass.php';
1708 + $wp_hasher = new PasswordHash( 8, true );
2024 1709 }
2025 -
1710 + $hashed = $wp_hasher->HashPassword( $key );
1711 + $wpdb->update( $wpdb->users, array( 'user_activation_key' => time() . ':' . $hashed ), array( 'user_login' => $user_data->user_login ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
2026 1712 $message = '<p>' . __( 'You have requested to reset your password for the following account:', 'userswp' ) . '</p>';
2027 1713 $message .= home_url( '/' ) . '</p>';
2028 1714 $message .= '<p>' . sprintf( __( 'Username: %s', 'userswp' ), $user_data->user_login ) . '</p>';
2029 1715 $message .= '<p>' . __( 'If this was by mistake, just ignore this email and nothing will happen.', 'userswp' ) . '</p>';
@@ -2316,21 +2002,8 @@
2316 2002 unset( $uploads_result[ $upload_file_key ] );
2317 2003 }
2318 2004 }
2319 2005
2320 - global $wpdb;
2321 - $file_field_names = $wpdb->get_col(
2322 - $wpdb->prepare(
2323 - "SELECT htmlvar_name FROM " . uwp_get_table_prefix() . "uwp_form_fields WHERE form_type = %s AND field_type IN ('file','image')",
2324 - 'account'
2325 - )
2326 - );
2327 - foreach ( $file_field_names as $file_field_name ) {
2328 - if ( isset( $result[ $file_field_name ] ) && ! isset( $uploads_result[ $file_field_name ] ) ) {
2329 - unset( $result[ $file_field_name ] );
2330 - }
2331 - }
2332 -
2333 2006 $result = array_merge( $result, $uploads_result );
2334 2007
2335 2008 $args = array(
2336 2009 'ID' => get_current_user_id(),
@@ -2560,94 +2233,46 @@
2560 2233 * @package userswp
2561 2234 * @since 1.0.0
2562 2235 */
2563 2236 public function upload_file_remove() {
2564 - global $wpdb;
2565 -
2566 2237 check_ajax_referer( 'uwp_basic_nonce', 'security' );
2567 2238
2568 - // Check user logged in.
2569 - if ( ! is_user_logged_in() ) {
2570 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Access denied!', 'userswp' ) ) );
2571 - wp_send_json_error( array( 'message' => $message ) );
2572 - }
2573 -
2239 + $htmlvar = esc_sql( strip_tags( $_POST['htmlvar'] ) );
2574 2240 $user_id = ! empty( $_POST['uid'] ) ? absint( $_POST['uid'] ) : 0;
2575 - $htmlvar = ! empty( $_POST['htmlvar'] ) ? sanitize_key( $_POST['htmlvar'] ) : '';
2576 2241
2577 - if ( empty( $user_id ) || empty( $htmlvar ) ) {
2578 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid data!', 'userswp' ) ) );
2579 - wp_send_json_error( array( 'message' => $message ) );
2242 + if ( empty( $user_id ) ) {
2243 + wp_die( -1 );
2580 2244 }
2581 2245
2582 - // Validate the user / admin.
2583 - if ( ! ( $user_id == (int) get_current_user_id() || current_user_can( 'manage_options' ) ) ) {
2584 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid access!', 'userswp' ) ) );
2585 - wp_send_json_error( array( 'message' => $message ) );
2246 + if ( ! ( is_user_logged_in() && ( $user_id == (int) get_current_user_id() || current_user_can( 'manage_options' ) ) ) ) {
2247 + wp_send_json_error( __( 'Invalid access!', 'userswp' ) );
2586 2248 }
2587 2249
2250 + // Remove file
2588 2251 if ( $htmlvar == 'banner_thumb' ) {
2589 - $field_key = 'banner';
2252 + $file = uwp_get_usermeta( $user_id, 'banner_thumb' );
2590 2253 $type = 'banner';
2591 - } else if ( $htmlvar == 'avatar_thumb' ) {
2592 - $field_key = 'avatar';
2254 + } elseif ( $htmlvar == 'avatar_thumb' ) {
2255 + $file = uwp_get_usermeta( $user_id, 'avatar_thumb' );
2593 2256 $type = 'avatar';
2594 2257 } else {
2595 - $field_key = $htmlvar;
2258 + $file = '';
2596 2259 $type = '';
2597 2260 }
2598 2261
2599 - $field = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . uwp_get_table_prefix() . "uwp_form_fields WHERE htmlvar_name = %s LIMIT 1", $field_key ) );
2600 -
2601 - // Check field exists.
2602 - if ( empty( $field ) ) {
2603 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid field!', 'userswp' ) ) );
2604 - wp_send_json_error( array( 'message' => $message ) );
2605 - }
2606 -
2607 - // Validate field access.
2608 - if ( ! empty( $field->for_admin_use ) && ! current_user_can( 'manage_options' ) ) {
2609 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'You are not allowed to perform this action!', 'userswp' ) ) );
2610 - wp_send_json_error( array( 'message' => $message ) );
2611 - }
2612 -
2613 - if ( ! in_array( $field->field_type, array( 'file', 'image' ) ) ) {
2614 - $message = aui()->alert( array( 'type' => 'error', 'content' => __( 'Invalid field type!', 'userswp' ) ) );
2615 - wp_send_json_error( array( 'message' => $message ) );
2616 - }
2617 -
2618 - $value = uwp_get_usermeta( $user_id, $htmlvar );
2619 -
2620 2262 uwp_update_usermeta( $user_id, $htmlvar, '' );
2621 2263
2622 - if ( $value && validate_file( $value ) === 0 ) {
2264 + if ( $file ) {
2623 2265 $uploads = wp_upload_dir();
2624 2266 $upload_path = $uploads['basedir'];
2267 + $unlink_file = untrailingslashit( $upload_path ) . '/' . ltrim( $file, '/' );
2625 2268
2626 - if ( strpos( $value, 'http://' ) === 0 || strpos( $value, 'https://' ) === 0 ) {
2627 - // Get the relative url.
2628 - $value = uwp_get_file_relative_url( $value );
2629 - }
2269 + if ( is_file( $unlink_file ) && file_exists( $unlink_file ) ) {
2270 + @unlink( $unlink_file );
2271 + $unlink_ori_file = str_replace( '_uwp_' . $type . '_thumb' . '.', '.', $unlink_file );
2630 2272
2631 - $unlink_file = untrailingslashit( $upload_path ) . '/' . trim( $value, '/\\' );
2632 -
2633 - // Canonicalize and enforce containment inside the uploads directory before deleting.
2634 - $real_upload_path = realpath( $upload_path );
2635 - $real_unlink_file = realpath( $unlink_file );
2636 -
2637 - if ( $real_upload_path && $real_unlink_file && is_file( $real_unlink_file )
2638 - && strpos( $real_unlink_file, $real_upload_path . DIRECTORY_SEPARATOR ) === 0 ) {
2639 - wp_delete_file( $real_unlink_file );
2640 -
2641 - // For avatar/banner, also remove the original (non-thumb) file.
2642 - if ( $type ) {
2643 - $unlink_ori_file = str_replace( '_uwp_' . $type . '_thumb' . '.', '.', $real_unlink_file );
2644 - $real_unlink_ori_file = realpath( $unlink_ori_file );
2645 -
2646 - if ( $real_unlink_ori_file && is_file( $real_unlink_ori_file )
2647 - && strpos( $real_unlink_ori_file, $real_upload_path . DIRECTORY_SEPARATOR ) === 0 ) {
2648 - wp_delete_file( $real_unlink_ori_file );
2649 - }
2273 + if ( is_file( $unlink_ori_file ) && file_exists( $unlink_ori_file ) ) {
2274 + @unlink( $unlink_ori_file );
2650 2275 }
2651 2276 }
2652 2277 }
2653 2278
@@ -2893,9 +2518,9 @@
2893 2518 'help_text' => wp_kses_post( uwp_get_field_description( $field ) ),
2894 2519 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
2895 2520 'validation_pattern' => ! empty( $field->validation_pattern ) ? esc_attr( wp_unslash( $field->validation_pattern ) ) : '',
2896 2521 'extra_attributes' => $extra_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2897 - 'input_group_right' => '<div class="input-group-text px-2 bg-transparent border-0x" onclick="jQuery(this).parent().parent().find(\'input\').val(\'\');"><i class="fas fa-times uwp-search-input-label-clear text-muted c-pointer" title="' . esc_attr__( 'Clear field', 'userswp' ) . '" ></i></div>',
2522 + 'input_group_right' => '<div class="input-group-text px-2 bg-transparent border-0x" onclick="jQuery(this).parent().parent().find(\'input\').val(\'\');"><i class="fas fa-times uwp-search-input-label-clear text-muted c-pointer" title="' . esc_attr__( 'Clear field', 'uwp-search' ) . '" ></i></div>',
2898 2523 )
2899 2524 );
2900 2525 } else {
2901 2526 ?>
@@ -4129,26 +3754,17 @@
4129 3754 $site_title = uwp_get_form_label( $field );
4130 3755 $required_msg = ( ! empty( $field->is_required ) && $field->required_msg != '') ? __( stripslashes( $field->required_msg ), 'userswp' ) : '';
4131 3756 $validation_text = ! empty( $field->validation_msg ) ? __( stripslashes( $field->validation_msg ), 'userswp' ) : '';
4132 3757
4133 - $is_forgot_email = ( $form_type === 'forgot' && $field->htmlvar_name === 'email' );
4134 - $input_type = $is_forgot_email ? 'text' : 'email';
4135 - if ( $is_forgot_email ) {
4136 - $site_title = __( 'Username or Email', 'userswp' );
4137 - $placeholder = $site_title . ( ! empty( $field->is_required ) ? ' *' : '' );
4138 - } else {
4139 - $placeholder = uwp_get_field_placeholder( $field );
4140 - }
4141 -
4142 3758 if ( $design_style ) {
4143 3759 $required = ! empty( $field->is_required ) ? ' <span class="text-danger">*</span>' : '';
4144 3760
4145 3761 echo aui()->input(
4146 3762 array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
4147 - 'type' => $input_type,
3763 + 'type' => 'email',
4148 3764 'id' => esc_attr( $field->htmlvar_name ),
4149 3765 'name' => esc_attr( $field->htmlvar_name ),
4150 - 'placeholder' => esc_attr( $placeholder ),
3766 + 'placeholder' => esc_attr( uwp_get_field_placeholder( $field ) ),
4151 3767 'title' => esc_html( $site_title ),
4152 3768 'value' => esc_attr( wp_unslash( $value ) ),
4153 3769 'required' => (bool) $field->is_required,
4154 3770 'validation_text' => $validation_text != '' ? esc_attr( $validation_text ) : esc_attr( $required_msg ),
@@ -4184,9 +3800,9 @@
4184 3800
4185 3801 <input name="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4186 3802 class="<?php echo esc_attr( $field->css_class ); ?> uwp_textfield <?php echo esc_attr( $bs_form_control ); ?>"
4187 3803 id="<?php echo esc_attr( $field->htmlvar_name ); ?>"
4188 - placeholder="<?php echo esc_attr( $placeholder ); ?>"
3804 + placeholder="<?php echo esc_attr( uwp_get_field_placeholder( $field ) ); ?>"
4189 3805 value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
4190 3806 title="<?php echo esc_attr( $site_title ); ?>"
4191 3807 <?php
4192 3808 if ( $field->is_required == 1 ) {
@@ -4192,9 +3808,9 @@
4192 3808 if ( $field->is_required == 1 ) {
4193 3809 echo 'required="required"';
4194 3810 }
4195 3811 ?>
4196 - type="<?php echo esc_attr( $input_type ); ?>"
3812 + type="email"
4197 3813 />
4198 3814 <span class="uwp_message_note"><?php echo wp_kses_post( uwp_get_field_description( $field ) ); ?></span>
4199 3815 <?php if ( $field->is_required ) { ?>
4200 3816 <span class="uwp_message_error invalid-feedback"><?php echo esc_html__( stripslashes( $field->required_msg ), 'userswp' ); ?></span>
@@ -4690,9 +4306,9 @@
4690 4306 // If no html then we run the standard output.
4691 4307 if ( empty( $html ) ) {
4692 4308
4693 4309 $design_style = uwp_get_option( 'design_style', 'bootstrap' );
4694 - $bs_form_group = $design_style ? 'form-group m-0' : ''; // country wrapper div added by JS adds margin so we remove ours
4310 + $bs_form_group = $design_style ? 'form-group m-0' : ''; // country wrapper div added by JS adds marginso we remove ours
4695 4311 $bs_sr_only = $design_style ? 'sr-only' : '';
4696 4312 $bs_form_control = $design_style ? 'form-control' : '';
4697 4313
4698 4314 ob_start(); // Start buffering;
@@ -5255,13 +4871,13 @@
5255 4871 function (event) {
5256 4872 var $form = $(this).closest('form');
5257 4873 if( ! $form.hasClass('uwp-login-form') ) {
5258 4874 uwp_checkPasswordStrength(
5259 - $form.find('input[name=password]'),
5260 - $form.find('input[name=confirm_password]'),
5261 - $form.find('#uwp-password-strength'),
5262 - $form.find('button[type="submit"], input[type="submit"]'),
5263 - ['black', 'listed', 'word']
4875 + $('input[name=password]', $form), // First password field
4876 + $('input[name=confirm_password]', $form), // Second password field
4877 + $('#uwp-password-strength', $form), // Strength meter
4878 + $('input[type=submit]', $form), // Submit button
4879 + ['black', 'listed', 'word'] // Blacklisted words
5264 4880 );
5265 4881 }
5266 4882 }
5267 4883 );
@@ -5288,15 +4904,12 @@
5288 4904 public function ajax_forgot_password_form() {
5289 4905
5290 4906 // add the modal error container
5291 4907 add_action( 'uwp_template_display_notices', array( $this, 'modal_error_container' ) );
5292 - $args = array(
5293 - 'form_title' => '',
5294 - 'css_class' => ''
5295 - );
4908 +
5296 4909 // get the form
5297 4910 ob_start();
5298 - uwp_get_template( 'bootstrap/forgot.php', $args );
4911 + uwp_get_template( 'bootstrap/forgot.php' );
5299 4912 $form = ob_get_clean();
5300 4913
5301 4914 // bs5
5302 4915 if ( function_exists( 'aui_bs_convert_sd_output' ) ) {