PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.0.6
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.0.6
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 2.0.7 All 340 releases
profile-builder / front-end / default-fields / website / website.php

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

51 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /* handle field output */
3 function wppb_website_handler( $output, $form_location, $field, $user_id, $field_check_errors, $request_data ){
4 $item_title = apply_filters( 'wppb_'.$form_location.'_website_item_title', wppb_icl_t( 'plugin profile-builder-pro', 'default_field_'.$field['id'].'_title_translation', $field['field-title'] ) );
5 $item_description = wppb_icl_t( 'plugin profile-builder-pro', 'default_field_'.$field['id'].'_description_translation', $field['description'] );
6 $input_value = '';
7 if( $form_location == 'edit_profile' )
8 $input_value = get_the_author_meta( 'user_url', $user_id );
9
10 if ( trim( $input_value ) == '' )
11 $input_value = $field['default-value'];
12
13 $input_value = ( isset( $request_data['website'] ) ? trim( $request_data['website'] ) : $input_value );
14
15 if ( $form_location != 'back_end' ){
16 $error_mark = ( ( $field['required'] == 'Yes' ) ? '<span class="wppb-required" title="'.wppb_required_field_error($field["field-title"]).'">*</span>' : '' );
17
18 if ( array_key_exists( $field['id'], $field_check_errors ) )
19 $error_mark = '<img src="'.WPPB_PLUGIN_URL.'assets/images/pencil_delete.png" title="'.wppb_required_field_error($field["field-title"]).'"/>';
20
21 $output = '
22 <label for="website">'.$item_title.$error_mark.'</label>
23 <input class="text-input default_field_website" name="website" maxlength="'. apply_filters( 'wppb_maximum_character_length', 70 ) .'" type="text" id="website" value="'.esc_url( wp_unslash( $input_value ) ).'" />';
24 if( !empty( $item_description ) )
25 $output .= '<span class="wppb-description-delimiter">'. $item_description .'</span>';
26
27 }
28
29 return apply_filters( 'wppb_'.$form_location.'_website', $output, $form_location, $field, $user_id, $field_check_errors, $request_data );
30 }
31 add_filter( 'wppb_output_form_field_default-website', 'wppb_website_handler', 10, 6 );
32
33
34 /* handle field validation */
35 function wppb_check_website_value( $message, $field, $request_data, $form_location ){
36 if ( ( isset( $request_data['website'] ) && ( trim( $request_data['website'] ) == '' ) ) && ( $field['required'] == 'Yes' ) )
37 return wppb_required_field_error($field["field-title"]);
38
39 return $message;
40 }
41 add_filter( 'wppb_check_form_field_default-website', 'wppb_check_website_value', 10, 4 );
42
43
44 /* handle field save */
45 function wppb_userdata_add_website( $userdata, $global_request ){
46 if ( isset( $global_request['website'] ) )
47 $userdata['user_url'] = esc_url_raw( trim( $global_request['website'] ) );
48
49 return $userdata;
50 }
51 add_filter( 'wppb_build_userdata', 'wppb_userdata_add_website', 10, 2 );