PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.6
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.6
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
profile-builder / front-end / default-fields / password / password.php

password.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.9.6, at front-end/default-fields/password/password.php

76 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
4 /* handle field output */
5 function wppb_password_handler( $output, $form_location, $field, $user_id, $field_check_errors, $request_data ){
6
7
8 $item_title = apply_filters( 'wppb_'.$form_location.'_password_item_title', wppb_icl_t( 'plugin profile-builder-pro', 'default_field_'.$field['id'].'_title_translation', $field['field-title'], true ) );
9 $item_description = wppb_icl_t( 'plugin profile-builder-pro', 'default_field_'.$field['id'].'_description_translation', $field['description'], true );
10
11 if ( $form_location != 'back_end' ){
12 $error_mark = ( ( $field['required'] == 'Yes' ) ? ( $form_location != 'edit_profile' ? '<span class="wppb-required" title="'.wppb_required_field_error($field["field-title"]).'">*</span>' : '' ) : '' );
13
14 if ( array_key_exists( $field['id'], $field_check_errors ) )
15 $error_mark = '<img src="'.WPPB_PLUGIN_URL.'assets/images/pencil_delete.png" title="'.wppb_required_field_error($field["field-title"]).'"/>';
16
17 $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location );
18
19 $output = '
20 <label for="passw1">' . $item_title.$error_mark . '</label>
21 <input class="text-input '. apply_filters( 'wppb_fields_extra_css_class', '', $field ) .'" name="passw1" maxlength="'. apply_filters( 'wppb_maximum_character_length', 70, $field ) .'" type="password" id="passw1" value="" autocomplete="off" '. $extra_attr .'/>';
22
23 /* add the HTML for the visibility toggle */
24 $output .= wppb_password_visibility_toggle_html();
25
26 if( ! empty( $item_description ) )
27 $output .= '<span class="wppb-description-delimiter">'. $item_description .' '. wppb_password_length_text() .' '. wppb_password_strength_description() .'</span>';
28 else
29 $output .= '<span class="wppb-description-delimiter">'. wppb_password_length_text() .' '. wppb_password_strength_description() .'</span>';
30
31 /* if we have active the password strength checker */
32 $output .= wppb_password_strength_checker_html();
33
34 }
35
36 return apply_filters( 'wppb_'.$form_location.'_password', $output, $form_location, $field, $user_id, $field_check_errors, $request_data );
37 }
38 add_filter( 'wppb_output_form_field_default-password', 'wppb_password_handler', 10, 6 );
39
40 /* handle field validation */
41 function wppb_check_password_value( $message, $field, $request_data, $form_location ){
42
43 if ( $form_location == 'register' ){
44 if ( ( isset( $request_data['passw1'] ) && ( trim( $request_data['passw1'] ) == '' ) ) && ( $field['required'] == 'Yes' ) )
45 return wppb_required_field_error($field["field-title"]);
46
47 elseif ( !isset( $request_data['passw1'] ) && ( $field['required'] == 'Yes' ) )
48 return wppb_required_field_error($field["field-title"]);
49 }
50
51 if ( isset( $request_data['passw1'] ) && trim( $request_data['passw1'] ) != '' ){
52 $wppb_generalSettings = get_option( 'wppb_general_settings' );
53
54 if( wppb_check_password_length( $request_data['passw1'] ) )
55 return '<br/>'. sprintf( __( "The password must have the minimum length of %s characters", "profile-builder" ), $wppb_generalSettings['minimum_password_length'] );
56
57
58 if( wppb_check_password_strength() ){
59 return '<br/>' . sprintf( __( "The password must have a minimum strength of %s", "profile-builder" ), wppb_check_password_strength() );
60 }
61 }
62
63 return $message;
64 }
65 add_filter( 'wppb_check_form_field_default-password', 'wppb_check_password_value', 10, 4 );
66
67 /* handle field save */
68 function wppb_userdata_add_password( $userdata, $global_request, $form_args ){
69 if( wppb_field_exists_in_form( 'Default - Password', $form_args ) ) {
70 if (isset($global_request['passw1']) && (trim($global_request['passw1']) != ''))
71 $userdata['user_pass'] = trim($global_request['passw1']);
72 }
73
74 return $userdata;
75 }
76 add_filter( 'wppb_build_userdata', 'wppb_userdata_add_password', 10, 3 );