PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
← All changes | front-end/login.php +126 -63 3.9.84.0.3 View file →
@@ -31,10 +31,11 @@
31 31 }
32 32 }
33 33 }
34 34
35 + $redirect_to = '';
35 36 if ( isset( $_REQUEST['redirect_to'] ) ) {
36 - $redirect_to = esc_url_raw( $_REQUEST['redirect_to'] );
37 + $redirect_to = wppb_sanitize_request_url( $_REQUEST['redirect_to'] );
37 38 }
38 39
39 40 $user = wp_signon( array(), $secure_cookie );
40 41
@@ -45,9 +46,9 @@
45 46 'https://codex.wordpress.org/Cookies', 'https://wordpress.org/support/' ) );
46 47 }
47 48 }
48 49
49 - $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? esc_url_raw( $_REQUEST['redirect_to'] ) : '';
50 + $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? wppb_sanitize_request_url( $_REQUEST['redirect_to'] ) : '';
50 51 /**
51 52 * Filters the login redirect URL.
52 53 */
53 54 $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user );
@@ -115,15 +116,16 @@
115 116 'echo' => true,
116 117 // Default 'redirect' value takes the user back to the request URI.
117 118 'redirect' => $default_redirect,
118 119 'form_id' => 'wppb-loginform',
120 + 'form_classes' => array(),
119 121 'label_username' => __( 'Username or Email Address', 'profile-builder' ),
120 122 'login_username_input_type' => 'text',
121 123 'label_password' => __( 'Password', 'profile-builder' ),
122 124 'label_remember' => __( 'Remember Me', 'profile-builder' ),
123 125 'label_log_in' => __( 'Log In', 'profile-builder' ),
124 - 'id_username' => 'user_login',
125 - 'id_password' => 'user_pass',
126 + 'id_username' => 'wppb_user_login',
127 + 'id_password' => 'wppb_user_pass',
126 128 'id_remember' => 'rememberme',
127 129 'id_submit' => 'wp-submit',
128 130 'remember' => true,
129 131 'value_username' => '',
@@ -128,8 +130,9 @@
128 130 'remember' => true,
129 131 'value_username' => '',
130 132 // Set 'value_remember' to true to default the "Remember me" checkbox to checked.
131 133 'value_remember' => false,
134 + 'is_ajax_form' => false,
132 135 );
133 136
134 137 /**
135 138 * Filters the default login form output arguments.
@@ -150,8 +153,14 @@
150 153 * Filters content to display at the bottom of the login form.
151 154 */
152 155 $login_form_bottom = apply_filters( 'login_form_bottom', '', $args );
153 156
157 + if( !empty( $args['is_ajax_form'] ) ){
158 + $args['form_classes'][] = 'wppb-ajax-form';
159 + }
160 +
161 + $args['form_classes'] = implode( ' ', $args['form_classes'] );
162 +
154 163 if( in_the_loop() )
155 164 $form_location = 'page';
156 165 else
157 166 $form_location = 'widget';
@@ -157,15 +166,15 @@
157 166 $form_location = 'widget';
158 167
159 168 // if an error is being shown pass the original referer forward
160 169 if( isset( $_GET['wppb_referer_url'] ) ){
161 - $wppb_referer_url = esc_url_raw ( $_GET['wppb_referer_url'] );
170 + $wppb_referer_url = wppb_sanitize_request_url( $_GET['wppb_referer_url'] );
162 171 } else {
163 - $wppb_referer_url = esc_url_raw ( isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '' );
172 + $wppb_referer_url = wppb_sanitize_request_url( isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '' );
164 173 }
165 174
166 175 $form = '
167 - <form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="'. esc_url( wppb_curpageurl() ) .'" method="post">
176 + <form name="' . esc_attr( $args['form_id'] ) . '" id="' . esc_attr( $args['form_id'] ) . '" class="' . esc_attr( $args['form_classes'] ) . '" action="'. esc_url( wppb_curpageurl() ) .'" method="post">
168 177 ' . $login_form_top . '
169 178 <p class="wppb-form-field login-username'. apply_filters( 'wppb_login_field_extra_css_class', '', $args['id_username']) .'">
170 179 <label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
171 180 <input type="' . esc_attr( $args['login_username_input_type'] ) . '" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" />
@@ -171,19 +180,20 @@
171 180 <input type="' . esc_attr( $args['login_username_input_type'] ) . '" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" />
172 181 </p>
173 182 <p class="wppb-form-field login-password'. apply_filters( 'wppb_login_field_extra_css_class', '', $args['id_password']) .'">
174 183 <label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
175 - <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" '. apply_filters( 'wppb_login_password_extra_attributes', '' ) .'/>';
184 + <span class="wppb-password-field-container">
185 + <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" '. apply_filters( 'wppb_login_password_extra_attributes', '' ) .'/>
186 + '. wppb_password_visibility_toggle_html() .' <!-- add the HTML for the visibility toggle -->
187 + </span>
188 + </p>';
176 189
177 - /* add the HTML for the visibility toggle */
178 - $form .= wppb_password_visibility_toggle_html();
179 -
180 190 $form .='
181 - </p>
191 +
182 192 ' . $login_form_middle . '
183 193 ' . ( $args['remember'] ? '<p class="wppb-form-field login-remember"><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /><label for="' . esc_attr( $args['id_remember'] ) . '">' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . '
184 - <p class="login-submit">
185 - <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="'. esc_attr( apply_filters( 'wppb_login_submit_class', "button button-primary" ) ) . '" value="' . esc_attr( $args['label_log_in'] ) . '" />
194 + <p class="login-submit form-submit">
195 + <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="'. esc_attr( apply_filters( 'wppb_login_submit_class', "button button-primary" ) ) . '" value="' . esc_attr( $args['label_log_in'] ) . '"' . apply_filters( 'wppb_login_submit_button_extra_attributes', '' ) . ' />
186 196 <input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
187 197 </p>
188 198 <input type="hidden" name="wppb_login" value="true"/>
189 199 <input type="hidden" name="wppb_form_location" value="'. esc_attr( $form_location ) .'"/>
@@ -195,8 +205,13 @@
195 205 <input type="hidden" name="wppb_redirect_check" value="true"/>
196 206 ' . $login_form_bottom . '
197 207 </form>';
198 208
209 + // Remove whitespace if login_username_input_type is set to email
210 + if ( $args['login_username_input_type'] == 'email' ) {
211 + $form .= '<script>window.onload = function() { jQuery(document).ready(function($) { $("input[name=\"log\"]").on("keyup", function() { $(this).val( $.trim($(this).val()) ); }); }); }</script>';
212 + }
213 +
199 214 if ( $args['echo'] )
200 215 echo $form; /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ /* escaped above */
201 216 else
202 217 return $form;
@@ -237,9 +252,15 @@
237 252
238 253 // if this setting is active, the posted username is, in fact the user's email or username
239 254 if( isset( $wppb_generalSettings['loginWith'] ) && ( $wppb_generalSettings['loginWith'] == 'usernameemail' ) ) {
240 255 if( is_email( $_POST['log'] ) ) {
256 +
241 257 $username = $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM $wpdb->users WHERE user_email= %s LIMIT 1", sanitize_email( $_POST['log'] ) ) );
258 +
259 + // the username can have the format of an email address, so if we can't find a user that has an account with the detected email, we set the username as that email
260 + if( empty( $username ) )
261 + $username = sanitize_user( $_POST['log'] );
262 +
242 263 } else {
243 264 $username = sanitize_user( $_POST['log'] );
244 265 }
245 266
@@ -244,9 +265,8 @@
244 265 }
245 266
246 267 if( !empty( $username ) )
247 268 $_POST['log'] = $username;
248 -
249 269 else {
250 270 // if we don't have a username for the email entered we can't have an empty username because we will receive a field empty error
251 271 $_POST['log'] = 'this_is_an_invalid_email'.time();
252 272 }
@@ -282,9 +302,9 @@
282 302 if ( $sql_result ) {
283 303 wppb_signup_user_notification( sanitize_text_field( $sql_result['user_login'] ), sanitize_email( $sql_result['user_email'] ), $sql_result['activation_key'], $sql_result['meta'] );
284 304 $transient_key = Wordpress_Creation_Kit_PB::wck_generate_slug( $user_email );
285 305 set_transient('wppb_confirmation_email_already_sent_' . $transient_key, true, 900 );
286 - $error_string = '<strong>' . __('SUCCESS: ', 'profile-builder') . '</strong>' . sprintf( __( 'Activation email sent to %s', 'profile-builder' ), sanitize_email( $_GET['email'] ));
306 + $error_string = '<strong>' . __( 'SUCCESS: ', 'profile-builder') . '</strong>' . sprintf( __( 'Activation email sent to %s', 'profile-builder' ), $user_email );
287 307 $wppb_success_message_nonce = wp_create_nonce( 'wppb_login_error_'.$error_string);
288 308 $current_url = wppb_curpageurl();
289 309 $arr_params = array('loginerror' => urlencode(base64_encode($error_string)), '_wpnonce' => $wppb_success_message_nonce, 'request_form_location' => 'page', 'wppb_message_type' => 'success');
290 310 $redirect_to = add_query_arg($arr_params, $current_url);
@@ -391,9 +411,9 @@
391 411 if( isset( $_POST['wppb_login'] ) ){
392 412 if( is_wp_error( $user ) ) {
393 413 // if we don't have a successful login we must redirect to the url of the form, so make sure this happens
394 414 if( isset( $_POST['wppb_request_url'] ) )
395 - $redirect_to = esc_url_raw( $_POST['wppb_request_url'] );
415 + $redirect_to = wppb_sanitize_request_url( $_POST['wppb_request_url'] );
396 416 if( isset( $_POST['wppb_form_location'] ) )
397 417 $request_form_location = sanitize_text_field( $_POST['wppb_form_location'] );
398 418 $error_string = $user->get_error_message();
399 419
@@ -402,10 +422,11 @@
402 422 if (isset($wppb_generalSettings['loginWith'])) {
403 423
404 424 $lost_pass_url = site_url('/wp-login.php?action=lostpassword');
405 425 // if the Login shortcode has a lostpassword argument set, give the lost password error link that value
406 - if (!empty($_POST['wppb_lostpassword_url'])) {
407 - $lost_pass_url = esc_url_raw( $_POST['wppb_lostpassword_url'] );
426 + $lost_pass_url_input = wppb_sanitize_request_url( $_POST['wppb_lostpassword_url'] ?? '' );
427 + if ( $lost_pass_url_input !== '' ) {
428 + $lost_pass_url = $lost_pass_url_input;
408 429 if ( wppb_check_missing_http( $lost_pass_url ) )
409 430 $lost_pass_url = "http://" . $lost_pass_url;
410 431 }
411 432 //apply filter to allow changing Lost your Password link
@@ -414,18 +435,13 @@
414 435 /* start building the error string */
415 436 if( in_array( $user->get_error_code(), array( 'empty_username', 'empty_password', 'invalid_username', 'incorrect_password' ) ) )
416 437 $error_string = '<strong>' . __('ERROR: ', 'profile-builder') . '</strong>';
417 438
418 -
419 439 if ( $user->get_error_code() == 'empty_password' ) {
420 440 $error_string .= __( 'The password field is empty.', 'profile-builder' ) . ' ';
421 441 }
422 442
423 - if ($user->get_error_code() == 'incorrect_password') {
424 - $error_string .= __('The password you entered is incorrect.', 'profile-builder') . ' ';
425 - }
426 -
427 - if ( $user->get_error_code() == 'empty_username' ) {
443 + if ( $user->get_error_code() == 'empty_username' ) {
428 444 if ($wppb_generalSettings['loginWith'] == 'email')// if login with email is enabled change the word username with email
429 445 $error_string .= __('The email field is empty.', 'profile-builder') . ' ';
430 446 else if( $wppb_generalSettings['loginWith'] == 'usernameemail' )// if login with username and email is enabled change the word username with username or email
431 447 $error_string .= __('The username/email field is empty', 'profile-builder') . ' ';
@@ -432,21 +448,31 @@
432 448 else
433 449 $error_string .= __('The username field is empty', 'profile-builder') . ' ';
434 450 }
435 451
436 - if ($user->get_error_code() == 'invalid_username') {
437 - if ($wppb_generalSettings['loginWith'] == 'email')// if login with email is enabled change the word username with email
438 - $error_string .= __('Invalid email.', 'profile-builder') . ' ';
439 - else if( $wppb_generalSettings['loginWith'] == 'usernameemail' )// if login with username and email is enabled change the word username with username or email
440 - $error_string .= __('Invalid username or email.', 'profile-builder') . ' ';
441 - else
442 - $error_string .= __('Invalid username.', 'profile-builder') . ' ';
452 + if( apply_filters( 'wppb_login_use_old_error_messages', false ) ) {
453 +
454 + if ( $user->get_error_code() == 'incorrect_password' ) {
455 + $error_string .= __('The password you entered is incorrect.', 'profile-builder') . ' ';
456 + }
443 457
444 - $error_string = apply_filters('wppb_login_invalid_username_error_message', $error_string);
458 + if ( $user->get_error_code() == 'invalid_username' ) {
459 + if ($wppb_generalSettings['loginWith'] == 'email')// if login with email is enabled change the word username with email
460 + $error_string .= __('Invalid email.', 'profile-builder') . ' ';
461 + else if( $wppb_generalSettings['loginWith'] == 'usernameemail' )// if login with username and email is enabled change the word username with username or email
462 + $error_string .= __('Invalid username or email.', 'profile-builder') . ' ';
463 + else
464 + $error_string .= __('Invalid username.', 'profile-builder') . ' ';
465 +
466 + $error_string = apply_filters('wppb_login_invalid_username_error_message', $error_string);
467 + }
468 +
469 + } else if( in_array( $user->get_error_code(), array( 'incorrect_password', 'invalid_username' ) ) ) {
470 + $error_string .= __( 'The credentials you entered are incorrect.', 'profile-builder' ) . ' ';
445 471 }
446 472
447 - if( $user->get_error_code() == 'incorrect_password' || $user->get_error_code() == 'invalid_username' && empty( $message_check = apply_filters('wppb_login_invalid_username_error_message', '' )))
448 - $error_string .= '<a href="' . esc_url( $lost_pass_url ) . '" title="' . __('Password Lost and Found.', 'profile-builder') . '">' . __('Lost your password?', 'profile-builder') . '</a>';
473 + if( $user->get_error_code() == 'incorrect_password' || $user->get_error_code() == 'invalid_username' && empty( $message_check = apply_filters('wppb_login_invalid_username_error_message', '' )))
474 + $error_string .= '<a href="' . esc_url( $lost_pass_url ) . '" title="' . __('Password Lost and Found.', 'profile-builder') . '">' . __('Lost your password?', 'profile-builder') . '</a>';
449 475
450 476 }
451 477
452 478 // if the error string is empty it means that none of the fields were completed
@@ -458,10 +484,11 @@
458 484 $error_string = apply_filters('wppb_login_wp_error_message', $error_string, $user);
459 485 $wppb_error_string_nonce = wp_create_nonce( 'wppb_login_error_'.$error_string );
460 486
461 487 // encode the error string and send it as a GET parameter
462 - if ( isset($_POST['wppb_referer_url']) && $_POST['wppb_referer_url'] !== '' ) {
463 - $arr_params = array('loginerror' => urlencode(base64_encode($error_string)), '_wpnonce' => $wppb_error_string_nonce, 'request_form_location' => $request_form_location, 'wppb_referer_url' => urlencode(esc_url_raw( $_POST['wppb_referer_url'] )));
488 + $referer_url = wppb_sanitize_request_url( $_POST['wppb_referer_url'] ?? '' );
489 + if ( $referer_url !== '' ) {
490 + $arr_params = array('loginerror' => urlencode(base64_encode($error_string)), '_wpnonce' => $wppb_error_string_nonce, 'request_form_location' => $request_form_location, 'wppb_referer_url' => urlencode( $referer_url ));
464 491 } else {
465 492 $arr_params = array('loginerror' => urlencode(base64_encode($error_string)), '_wpnonce' => $wppb_error_string_nonce, 'request_form_location' => $request_form_location);
466 493 }
467 494
@@ -505,21 +532,54 @@
505 532 /* define a global so we now we have the shortcode login present */
506 533 global $wppb_login_shortcode;
507 534 $wppb_login_shortcode = true;
508 535
509 - extract( shortcode_atts( array( 'display' => true, 'redirect' => '', 'redirect_url' => '', 'logout_redirect_url' => wppb_curpageurl(), 'register_url' => '', 'lostpassword_url' => '', 'redirect_priority' => 'normal', 'show_2fa_field' => '', 'block' => false ), $atts ) );
536 + $atts = shortcode_atts( array(
537 + 'display' => true,
538 + 'redirect' => '',
539 + 'redirect_url' => '',
540 + 'logout_redirect_url' => wppb_curpageurl(),
541 + 'redirect_priority' => 'normal',
542 + 'register_url' => '',
543 + 'lostpassword_url' => '',
544 + 'show_2fa_field' => '',
545 + 'block' => false,
546 + 'ajax' => false,
547 + ), $atts, 'wppb-login' );
510 548
549 + $display = $atts['display'];
550 + $redirect = $atts['redirect'];
551 + $redirect_url = $atts['redirect_url'];
552 + $logout_redirect_url = $atts['logout_redirect_url'];
553 + $redirect_priority = $atts['redirect_priority'];
554 + $register_url = $atts['register_url'];
555 + $lostpassword_url = $atts['lostpassword_url'];
556 + $show_2fa_field = $atts['show_2fa_field'];
557 + $block = $atts['block'];
558 + $ajax = $atts['ajax'];
559 +
560 + $is_ajax_form = false;
561 + if( defined( 'WPPB_PAID_PLUGIN_DIR' ) && $ajax === 'true' && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/ajax/assets/forms-ajax-validation.js' ) ) {
562 + wp_enqueue_script( 'wppb-forms-ajax-validation-script', WPPB_PAID_PLUGIN_URL . 'features/ajax/assets/forms-ajax-validation.js', array( 'jquery' ), PROFILE_BUILDER_VERSION, true );
563 + wp_localize_script( 'wppb-forms-ajax-validation-script', 'submitButtonData', array( 'processingText' => __('Processing...', 'profile-builder') ) );
564 + $is_ajax_form = true;
565 + }
566 +
511 567 $wppb_generalSettings = get_option('wppb_general_settings');
512 568
513 569 // check if the form is being displayed in the Elementor editor
514 - $is_elementor_edit_mode = false;
570 + $is_elementor_edit_mode_or_divi_ajax = false;
515 571 if( class_exists ( '\Elementor\Plugin' ) ){
516 - $is_elementor_edit_mode = \Elementor\Plugin::$instance->editor->is_edit_mode();
572 + $is_elementor_edit_mode_or_divi_ajax = \Elementor\Plugin::$instance->editor->is_edit_mode();
517 573 }
518 574
519 - if( !is_user_logged_in() || $is_elementor_edit_mode || $block === 'true' ){
575 + if ( is_array( $_POST ) && array_key_exists( 'action', $_POST ) && $_POST['action'] === 'wppb_divi_extension_ajax' ) {
576 + $is_elementor_edit_mode_or_divi_ajax = true;
577 + }
578 +
579 + if( !is_user_logged_in() || $is_elementor_edit_mode_or_divi_ajax || $block === 'true' ){
520 580 // set up the form arguments
521 - $form_args = array( 'echo' => false, 'id_submit' => 'wppb-submit' );
581 + $form_args = array( 'echo' => false, 'id_submit' => 'wppb-submit', 'is_ajax_form' => $is_ajax_form );
522 582
523 583 // maybe set up the redirect argument
524 584 if( ! empty( $redirect ) ) {
525 585 $redirect_url = $redirect;
@@ -560,10 +620,10 @@
560 620 add_action( 'login_form_middle', array( $wppb_auth, 'auth_code_field') );
561 621 }
562 622 }
563 623
564 - // initialize our form variable
565 - $login_form = '';
624 + // initialize our form variable
625 + $login_form = '';
566 626
567 627 // display our login errors
568 628 if( ( isset( $_GET['loginerror'] ) || isset( $_POST['loginerror'] ) ) && isset( $_GET['_wpnonce'] ) ){
569 629 $error_string = urldecode( base64_decode( isset( $_GET['loginerror'] ) ? sanitize_text_field( $_GET['loginerror'] ) : sanitize_text_field( $_POST['loginerror'] ) ) );
@@ -570,9 +630,9 @@
570 630 if( wp_verify_nonce( sanitize_text_field( $_GET['_wpnonce'] ), 'wppb_login_error_'. $error_string ) ) {
571 631 if ( isset( $_GET['wppb_message_type'] ) && $_GET['wppb_message_type'] == 'success' )
572 632 $message_type = 'wppb-success';
573 633 else $message_type = 'wppb-error';
574 - $loginerror = '<p class="'. $message_type .'">' . wp_kses_post(str_replace( '-wppb-plus-', '+', $error_string)) . '</p><!-- .error -->';
634 + $loginerror = '<p class="'. $message_type .'" role="alert">' . wp_kses_post(str_replace( '-wppb-plus-', '+', $error_string)) . '</p><!-- .error -->';
575 635 if (isset($_GET['request_form_location'])) {
576 636 if ($_GET['request_form_location'] === 'widget' && !in_the_loop()) {
577 637 $login_form .= $loginerror;
578 638 } elseif ($_GET['request_form_location'] === 'page' && in_the_loop()) {
@@ -580,10 +640,10 @@
580 640 }
581 641 }
582 642 }
583 643 }
584 - // build our form
585 - $login_form .= '<div id="wppb-login-wrap" class="wppb-user-forms">';
644 + // build our form
645 + $login_form .= '<div id="wppb-login-wrap" class="wppb-user-forms">';
586 646
587 647 if ( empty( $lostpassword_url ) )
588 648 $lostpassword_url = ( !empty( $wppb_generalSettings['lost_password_page'] ) ) ? $wppb_generalSettings['lost_password_page'] : '';
589 649
@@ -614,29 +674,24 @@
614 674 }else{
615 675 $user_ID = get_current_user_id();
616 676 $wppb_user = get_userdata( $user_ID );
617 677
618 - if( isset( $wppb_generalSettings['loginWith'] ) && ( $wppb_generalSettings['loginWith'] == 'email' ) )
678 + $login_with = isset( $wppb_generalSettings['loginWith'] ) ? $wppb_generalSettings['loginWith'] : '';
679 +
680 + // Email login: always show the email. Username+email: show email when the login is the auto-generated slug from that email.
681 + if ( $login_with === 'email' ) {
619 682 $display_name = $wppb_user->user_email;
620 -
621 - elseif($wppb_user->display_name !== '')
622 - $display_name = $wppb_user->user_login;
623 -
624 - else
683 + } elseif ( $login_with === 'usernameemail'
684 + && $wppb_user->user_login === Wordpress_Creation_Kit_PB::wck_generate_slug( trim( $wppb_user->user_email ) ) ) {
685 + $display_name = $wppb_user->user_email;
686 + } elseif ( $wppb_user->display_name !== '' ) {
625 687 $display_name = $wppb_user->display_name;
626 -
627 - if( isset( $wppb_generalSettings['loginWith'] ) && ( $wppb_generalSettings['loginWith'] == 'usernameemail' ) )
628 - if( $wppb_user->user_login == Wordpress_Creation_Kit_PB::wck_generate_slug( trim( $wppb_user->user_email ) ) )
629 - $display_name = $wppb_user->user_email;
630 -
631 - elseif($wppb_user->display_name !== '')
688 + } else {
632 689 $display_name = $wppb_user->user_login;
690 + }
633 691
634 - else
635 - $display_name = $wppb_user->display_name;
692 + $logged_in_message = '<p class="wppb-alert" role="alert">';
636 693
637 - $logged_in_message = '<p class="wppb-alert">';
638 -
639 694 // CHECK FOR REDIRECT
640 695 $logout_redirect_url = wppb_get_redirect_url( $redirect_priority, 'after_logout', $logout_redirect_url, $wppb_user );
641 696 $logout_redirect_url = apply_filters( 'wppb_after_logout_redirect_url', $logout_redirect_url );
642 697
@@ -661,4 +716,12 @@
661 716
662 717 return $user;
663 718 }
664 719 add_filter( 'wp_authenticate_user', 'wppb_login_security_check', 10, 2 );
720 +
721 +
722 +// include missing scripts needed on Elementor Pages (Form inside an Elementor Popup)
723 +function wppb_login_scripts_and_styles() {
724 + if ( is_plugin_active('elementor-pro/elementor-pro.php') && defined( 'WPPB_PAID_PLUGIN_URL' ) )
725 + wp_enqueue_script( 'wppb_elementor_popup_script', WPPB_PAID_PLUGIN_URL . 'features/elementor-pro/assets/js/elementor-popup.js', array('jquery') );
726 +}
727 +add_action( 'elementor/frontend/after_enqueue_scripts', 'wppb_login_scripts_and_styles' );