PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.0
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.0
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 / last-name / last-name.php

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

60 lines 3.1 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_last_name_handler( $output, $form_location, $field, $user_id, $field_check_errors, $request_data ){
6 $item_title = apply_filters( 'wppb_'.$form_location.'_lastname_item_title', wppb_icl_t( 'plugin profile-builder-pro', 'default_field_'.$field['id'].'_title_translation', $field['field-title'], true ) );
7 $item_description = wppb_icl_t( 'plugin profile-builder-pro', 'default_field_'.$field['id'].'_description_translation', $field['description'], true );
8 $input_value = '';
9 if( $form_location == 'edit_profile' )
10 $input_value = get_the_author_meta( 'last_name', $user_id );
11
12 if ( trim( $input_value ) == '' )
13 $input_value = $field['default-value'];
14
15 $input_value = ( isset( $request_data['last_name'] ) ? trim( $request_data['last_name'] ) : $input_value );
16 $input_value = apply_filters( 'wppb_form_last_name_field_value', $input_value, $field, $form_location );
17
18 if ( $form_location != 'back_end' ){
19 $error_mark = ( ( $field['required'] == 'Yes' ) ? '<span class="wppb-required" title="'.wppb_required_field_error($field["field-title"]).'">*</span>' : '' );
20
21 if ( array_key_exists( $field['id'], $field_check_errors ) )
22 $error_mark = '<img src="'.WPPB_PLUGIN_URL.'assets/images/pencil_delete.png" title="'.wppb_required_field_error($field["field-title"]).'"/>';
23
24 $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location );
25
26 $output = '
27 <label for="last_name">'.$item_title.$error_mark.'</label>
28 <input class="text-input default_field_lastname '. apply_filters( 'wppb_fields_extra_css_class', '', $field ) .'" name="last_name" maxlength="'. apply_filters( 'wppb_maximum_character_length', 70, $field ) .'" type="text" id="last_name" value="'. esc_attr( wp_unslash( $input_value ) ) .'" '. $extra_attr .'/>';
29 if( !empty( $item_description ) )
30 $output .= '<span class="wppb-description-delimiter">'. $item_description .'</span>';
31 }
32
33 return apply_filters( 'wppb_'.$form_location.'_lastname', $output, $form_location, $field, $user_id, $field_check_errors, $request_data );
34 }
35 add_filter( 'wppb_output_form_field_default-last-name', 'wppb_last_name_handler', 10, 6 );
36
37
38 /* handle field validation */
39 function wppb_check_last_name_value( $message, $field, $request_data, $form_location ){
40 if( $field['required'] == 'Yes' ){
41 if( ( isset( $request_data['last_name'] ) && ( trim( $request_data['last_name'] ) == '' ) ) || !isset( $request_data['last_name'] ) ){
42 return wppb_required_field_error($field["field-title"]);
43 }
44 }
45
46 return $message;
47 }
48 add_filter( 'wppb_check_form_field_default-last-name', 'wppb_check_last_name_value', 10, 4 );
49
50
51 /* handle field save */
52 function wppb_userdata_add_last_name( $userdata, $global_request, $form_args ){
53 if( wppb_field_exists_in_form( 'Default - Last Name', $form_args ) ) {
54 if (isset($global_request['last_name']))
55 $userdata['last_name'] = sanitize_text_field(trim($global_request['last_name']));
56 }
57
58 return $userdata;
59 }
60 add_filter( 'wppb_build_userdata', 'wppb_userdata_add_last_name', 10, 3 );