| @@ -48,9 +48,9 @@ | ||
| 48 | 48 | * |
| 49 | 49 | */ |
| 50 | 50 | function wppb_create_recover_password_form( $user, $post_data, $is_ajax_form = false ){ |
| 51 | 51 | ?> |
| 52 | - <form enctype="multipart/form-data" method="post" id="wppb-recover-password" class="wppb-user-forms<?php echo ($is_ajax_form ? ' wppb-ajax-form' : ''); ?>" action="<?php echo esc_url( wppb_curpageurl() ); ?>"> | |
| 52 | + <form enctype="multipart/form-data" method="post" novalidate id="wppb-recover-password" class="wppb-user-forms<?php echo ($is_ajax_form ? ' wppb-ajax-form' : ''); ?>" action="<?php echo esc_url( wppb_curpageurl() ); ?>"> | |
| 53 | 53 | <ul> |
| 54 | 54 | <?php |
| 55 | 55 | |
| 56 | 56 | if( !empty( $post_data['passw1'] ) ) |
| @@ -109,9 +109,9 @@ | ||
| 109 | 109 | * |
| 110 | 110 | */ |
| 111 | 111 | function wppb_create_generate_password_form( $post_data, $is_ajax_form = false ){ |
| 112 | 112 | ?> |
| 113 | - <form enctype="multipart/form-data" method="post" id="wppb-recover-password" class="wppb-user-forms<?php echo ($is_ajax_form ? ' wppb-ajax-form' : ''); ?>" action="<?php echo esc_url( wppb_curpageurl() ); ?>"> | |
| 113 | + <form enctype="multipart/form-data" method="post" novalidate id="wppb-recover-password" class="wppb-user-forms<?php echo ($is_ajax_form ? ' wppb-ajax-form' : ''); ?>" action="<?php echo esc_url( wppb_curpageurl() ); ?>"> | |
| 114 | 114 | <?php |
| 115 | 115 | $wppb_generalSettings = get_option( 'wppb_general_settings' ); |
| 116 | 116 | |
| 117 | 117 | if( !empty( $wppb_generalSettings['loginWith'] ) && $wppb_generalSettings['loginWith'] == 'email' ){ |
| @@ -130,9 +130,9 @@ | ||
| 130 | 130 | |
| 131 | 131 | $recover_input = '<ul> |
| 132 | 132 | <li class="wppb-form-field wppb-username-email'. apply_filters( 'wppb_recover_field_extra_css_class', '', 'username_email') .'"> |
| 133 | 133 | <label for="username_email">'. esc_html( $username_email_label ) .'</label> |
| 134 | - <input class="text-input" name="username_email" type="text" id="username_email" value="'.esc_attr( trim( $username_email ) ).'" '. apply_filters( 'wppb_recover_password_extra_attr', '', esc_html( $username_email_label ), 'username_email' ) .' /> | |
| 134 | + <input class="text-input" name="username_email" type="text" id="username_email" value="'.esc_attr( trim( $username_email ) ).'" required '. apply_filters( 'wppb_recover_password_extra_attr', '', esc_html( $username_email_label ), 'username_email' ) .' /> | |
| 135 | 135 | </li><!-- .username_email --></ul>'; |
| 136 | 136 | echo apply_filters( 'wppb_recover_password_generate_password_input', $recover_input, trim( $username_email ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 137 | 137 | ?> |
| 138 | 138 | <p class="form-submit"> |
| @@ -304,10 +304,17 @@ | ||
| 304 | 304 | $username_email = ''; |
| 305 | 305 | |
| 306 | 306 | //check to see if it's an e-mail (and if this is valid/present in the database) or is a username |
| 307 | 307 | |
| 308 | - // if we do not have an email in the posted date we try to get the email for that user | |
| 309 | - if( !is_email( $username_email ) ){ | |
| 308 | + if( $username_email === '' ){ | |
| 309 | + if( !empty( $wppb_generalSettings['loginWith'] ) && $wppb_generalSettings['loginWith'] == 'email' ) | |
| 310 | + $warning = __( 'Please enter your email address.', 'profile-builder' ); | |
| 311 | + else | |
| 312 | + $warning = __( 'Please enter your username or email address.', 'profile-builder' ); | |
| 313 | + $warning = apply_filters( 'wppb_recover_password_sent_message_empty', $warning ); | |
| 314 | + $output .= wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); | |
| 315 | + } elseif ( !is_email( $username_email ) ){ | |
| 316 | + // if we do not have an email in the posted date we try to get the email for that user | |
| 310 | 317 | // When filter is enabled and login is set to email only, do not allow username for password reset |
| 311 | 318 | if ( apply_filters( 'wppb_recover_password_require_email_when_login_with_email', false ) && !empty( $wppb_generalSettings['loginWith'] ) && $wppb_generalSettings['loginWith'] == 'email' ) { |
| 312 | 319 | $warning = __( 'Please enter your email address to request a password reset.', 'profile-builder' ); |
| 313 | 320 | $warning = apply_filters( 'wppb_recover_password_sent_message_username_not_allowed', $warning ); |