function wppb_html_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'HTML') { $item_title = apply_filters('wppb_' . $form_location . '_html_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'back_end') { $output = ' <label>' . $item_title . '</label> <span class="custom_field_html ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>' . do_shortcode($field['html-content']) . '</span>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $output = ' <table class="form-table"> <tr> <th><label>' . $item_title . '</label></th> <td> <span class="custom_field_html" ' . $extra_attr . '>' . do_shortcode($field['html-content']) . '</span> <br><span class="description">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_html_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $field['html-content']); } }
function wppb_description_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { $item_title = apply_filters('wppb_' . $form_location . '_description_item_title', wppb_icl_t('plugin profile-builder-pro', 'default_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'default_field_' . $field['id'] . '_description_translation', $field['description']); $input_value = ''; if ($form_location == 'edit_profile') { $input_value = get_the_author_meta('description', $user_id); } if (trim($input_value) == '') { $input_value = $field['default-value']; } $input_value = isset($request_data['description']) ? trim($request_data['description']) : $input_value; $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="description">' . $item_title . $error_mark . '</label> <textarea rows="' . $field['row-count'] . '" name="description" maxlength="' . apply_filters('wppb_maximum_character_length', '', $field) . '" class="default_field_description" id="description" wrap="virtual" ' . $extra_attr . '>' . esc_textarea(wp_unslash($input_value)) . '</textarea>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } return apply_filters('wppb_' . $form_location . '_description', $output, $form_location, $field, $user_id, $field_check_errors, $request_data); }
function wppb_ecf_email_confirmation_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Email Confirmation') { $item_title = apply_filters('wppb_' . $form_location . '_email_confirmation_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location == 'edit_profile') { $input_value = get_the_author_meta('user_email', $user_id); } else { $input_value = ''; } $input_value = isset($request_data['wppb_email_confirmation']) ? trim($request_data['wppb_email_confirmation']) : $input_value; $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="wppb_email_confirmation">' . $item_title . $error_mark . '</label> <input class="extra_field_email_confirmation" name="wppb_email_confirmation" type="text" id="wppb_email_confirmation" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } return apply_filters('wppb_' . $form_location . '_email_confirmation_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_multiple_select_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Select (Multiple)') { $item_title = apply_filters('wppb_' . $form_location . '_multiple_select_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $item_option_labels = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_option_labels_translation', $field['labels']); $select_labels = explode(',', $item_option_labels); $select_values = explode(',', $field['options']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'register') { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? array_map('trim', explode(',', get_user_meta($user_id, $field['meta-name'], true))) : array_map('trim', explode(',', $field['default-options'])); } else { $input_value = isset($field['default-options']) ? array_map('trim', explode(',', $field['default-options'])) : array(); } $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? array_map('trim', $request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value; if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label> <select name="' . $field['meta-name'] . '[]" id="' . $field['meta-name'] . '" size="' . (count($select_values) > 10 ? count($select_values) / 2 : count($select_values)) . '" class="custom_field_multiple_select ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" multiple="multiple" ' . $extra_attr . '>'; foreach ($select_values as $key => $value) { $output .= '<option value="' . trim($value) . '" class="custom_field_multiple_select_option" name="' . trim($value) . '_' . $field['id'] . '" id="' . trim($value) . '_' . $field['id'] . '"'; if (in_array(trim($value), $input_value)) { $output .= ' selected'; } $output .= '>' . (!isset($select_labels[$key]) || !$select_labels[$key] ? trim($select_values[$key]) : trim($select_labels[$key])) . '</option>'; } $output .= ' </select>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td> <select name="' . $field['meta-name'] . '[]" class="custom_field_multiple_select" id="' . $field['meta-name'] . '" multiple="multiple" ' . $extra_attr . '>'; foreach ($select_values as $key => $value) { $output .= '<option value="' . trim($value) . '" size="' . (count($select_values) > 10 ? count($select_values) / 2 : count($select_values)) . '" class="custom_field_multiple_select_option" id="' . trim($value) . '_' . $field['id'] . '"'; if (in_array(trim($value), $input_value)) { $output .= ' selected'; } $output .= '>' . (!isset($select_labels[$key]) || !$select_labels[$key] ? trim($select_values[$key]) : trim($select_labels[$key])) . '</option>'; } $output .= '</select> <span class="description">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_multiple_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_map_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Map') { // Enqueue scripts only if the API key is present if (!empty($field['map-api-key'])) { // Enqueue needed scripts wp_enqueue_script('wppb-google-maps-api-script', 'https://maps.googleapis.com/maps/api/js?key=' . $field['map-api-key'] . '&libraries=places', array('jquery'), PROFILE_BUILDER_VERSION, true); wp_enqueue_script('wppb-google-maps-script', WPPB_PLUGIN_URL . 'front-end/extra-fields/map/map.js', array('jquery'), PROFILE_BUILDER_VERSION, true); if ($form_location == 'back_end') { wp_enqueue_style('wppb-google-maps-style', WPPB_PLUGIN_URL . 'front-end/extra-fields/map/map.css', array(), PROFILE_BUILDER_VERSION); } } $item_title = apply_filters('wppb_' . $form_location . '_map_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); // Get saved map markers $map_markers = !empty($request_data[wppb_handle_meta_name($field['meta-name'])]) ? $request_data[wppb_handle_meta_name($field['meta-name'])] : wppb_get_user_map_markers($user_id, $field['meta-name']); if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = '<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>'; if (!empty($field['map-api-key'])) { // Map container that will be initialized through JS $output .= wppb_get_map_output($field, array('markers' => $map_markers, 'extra_attr' => $extra_attr)); if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { if (current_user_can('manage_options')) { $output .= '<div class="wppb-warning">' . __('Please add the Google Maps API key for this field.', 'profile-builder') . '</div>'; } } } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td>'; if (!empty($field['map-api-key'])) { // Map container that will be initialized through JS $output .= '<div style="max-width: 600px;">'; $output .= wppb_get_map_output($field, array('markers' => $map_markers, 'extra_attr' => $extra_attr)); $output .= '</div>'; $output .= '<span class="description">' . $item_description . '</span>'; } else { if (current_user_can('manage_options')) { $output .= '<div class="wppb-warning">' . __('Please add the Google Maps API key for this field.', 'profile-builder') . '</div>'; } } $output .= '</td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_map_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $map_markers); } }
function wppb_checkbox_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Checkbox') { $item_title = apply_filters('wppb_' . $form_location . '_checkbox_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $item_option_labels = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_option_labels_translation', $field['labels']); $checkbox_labels = explode(',', $item_option_labels); $checkbox_values = explode(',', $field['options']); if ($form_location != 'register') { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? array_map('trim', explode(',', stripslashes(get_user_meta($user_id, $field['meta-name'], true)))) : array_map('trim', explode(',', $field['default-options'])); } else { $input_value = !empty($field['default-options']) ? array_map('trim', explode(',', $field['default-options'])) : array(); } if ($form_location == 'register' && isset($request_data[wppb_handle_meta_name($field['meta-name'])]) && !empty($request_data[wppb_handle_meta_name($field['meta-name'])])) { $input_value = $request_data[wppb_handle_meta_name($field['meta-name'])]; } $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>'; $output .= '<ul class="wppb-checkboxes">'; foreach ($checkbox_values as $key => $value) { $output .= '<li><input value="' . esc_attr(trim($value)) . '" class="custom_field_checkbox" name="' . $field['meta-name'] . '[]" id="' . Wordpress_Creation_Kit_PB::wck_generate_slug(trim($value)) . '_' . $field['id'] . '" type="checkbox" ' . $extra_attr . ' '; if (in_array(trim($value), $input_value)) { $output .= ' checked'; } $output .= ' /><label for="' . Wordpress_Creation_Kit_PB::wck_generate_slug(trim($value)) . '_' . $field['id'] . '" class="wppb-rc-value">' . (!isset($checkbox_labels[$key]) || !$checkbox_labels[$key] ? trim($checkbox_values[$key]) : trim($checkbox_labels[$key])) . '</label></li>'; } $output .= '</ul>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td>'; foreach ($checkbox_values as $key => $value) { $output .= '<li><input value="' . esc_attr(trim($value)) . '" class="custom_field_checkbox ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" name="' . $field['meta-name'] . '[]" id="' . Wordpress_Creation_Kit_PB::wck_generate_slug(trim($value)) . '_' . $field['id'] . '" type="checkbox"'; if (in_array(trim($value), $input_value)) { $output .= ' checked'; } $output .= ' /><label for="' . Wordpress_Creation_Kit_PB::wck_generate_slug(trim($value)) . '_' . $field['id'] . '" class="wppb-rc-value">' . (!isset($checkbox_labels[$key]) || !$checkbox_labels[$key] ? trim($checkbox_values[$key]) : trim($checkbox_labels[$key])) . '</label></li>'; } $output .= ' <span class="wppb-description-delimiter">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_checkbox_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_timezone_select_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Select (Timezone)') { $item_title = apply_filters('wppb_' . $form_location . '_timezone_select_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $timezone_array = wppb_timezone_select_options($form_location); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'register') { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? stripslashes(get_user_meta($user_id, $field['meta-name'], true)) : $field['default-option-timezone']; } else { $input_value = !empty($field['default-option-timezone']) ? trim($field['default-option-timezone']) : ''; } $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value; if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label> <select name="' . $field['meta-name'] . '" id="' . $field['meta-name'] . '" class="custom_field_timezone_select ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>'; foreach ($timezone_array as $timezone) { $output .= '<option value="' . $timezone . '"'; if ($input_value === $timezone) { $output .= ' selected'; } $output .= '>' . $timezone . '</option>'; } $output .= ' </select>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td> <select name="' . $field['meta-name'] . '" class="custom_field_timezone_select" id="' . $field['meta-name'] . '" ' . $extra_attr . '>'; foreach ($timezone_array as $timezone) { $output .= '<option value="' . $timezone . '"'; if ($input_value === $timezone) { $output .= ' selected'; } $output .= '>' . $timezone . '</option>'; } $output .= '</select> <span class="description">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_timezone_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_default_about_yourself_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Default - About Yourself (Heading)') { $item_title = apply_filters('wppb_' . $form_location . '_default_heading_about_yourself_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'default_field_' . $field['id'] . '_description_translation', $field['description']); $output = '<h4>' . $item_title . '</h4><span class="wppb-description-delimiter">' . $item_description . '</span>'; return apply_filters('wppb_' . $form_location . '_default_heading_about_yourself_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data); } }
function wppb_heading_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Heading') { $item_title = apply_filters('wppb_' . $form_location . '_heading_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $heading_element1 = $form_location == 'back_end' ? '<h3>' : '<h4>'; $heading_element2 = $form_location == 'back_end' ? '</h3>' : '</h4>'; $output = $heading_element1 . $item_title . $heading_element2 . '<span class="wppb-description-delimiter">' . $item_description . '</span>'; return apply_filters('wppb_' . $form_location . '_heading_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data); } }
function wppb_colorpicker_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Colorpicker') { wp_enqueue_style('wp-color-picker'); wp_enqueue_style('profile-builder-colorpicker', WPPB_PLUGIN_URL . 'front-end/extra-fields/colorpicker/colorpicker-style.css', false, PROFILE_BUILDER_VERSION); wp_enqueue_script('iris', admin_url('js/iris.min.js'), array('jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch'), false, 1); wp_enqueue_script('wp-color-picker', admin_url('js/color-picker.min.js'), array('iris'), false, 1); wp_enqueue_script('wppb-colorpicker-script', WPPB_PLUGIN_URL . 'front-end/extra-fields/colorpicker/script-colorpicker.js', array('wp-color-picker'), PROFILE_BUILDER_VERSION, true); if (!is_admin()) { $is_frontend = array('isFrontend' => 1); } else { $is_frontend = array('isFrontend' => 0); } wp_localize_script('wppb-colorpicker-script', 'wppb_colorpicker_data', $is_frontend); $item_title = apply_filters('wppb_' . $form_location . '_colorpicker_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $field['default-value'] = apply_filters('wppb_colorpicker_default_color_' . $field['meta-name'], ''); if ($form_location != 'register') { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : $field['default-value']; } else { $input_value = !empty($field['default-value']) ? trim($field['default-value']) : ''; } $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value; $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label> <input name="' . $field['meta-name'] . '" class="custom_field_colorpicker ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" type="text" value="' . esc_attr(wp_unslash($input_value)) . '" data-default-color="' . $field['default-value'] . '" ' . $extra_attr . ' /> <span class="wppb-description-delimiter">' . $item_description . '</span>'; } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td> <input size="45" id="' . $field['meta-name'] . '" class="custom_field_colorpicker" name="' . $field['meta-name'] . '" type="text" value="' . esc_attr($input_value) . ' " ' . $extra_attr . '/> <span class="description">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_colorpicker_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_display_name_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { $item_title = apply_filters('wppb_' . $form_location . '_display-name_item_title', wppb_icl_t('plugin profile-builder-pro', 'default_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'default_field_' . $field['id'] . '_description_translation', $field['description']); if ($form_location == 'edit_profile') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } /* * Create the options for the display_name drop-down * They are created same as in user-edit.php of the WordPress core */ $user_data = get_userdata($user_id); $public_display = array(); $public_display['display_nickname'] = $user_data->nickname; $public_display['display_username'] = $user_data->user_login; if (!empty($user_data->first_name)) { $public_display['display_firstname'] = $user_data->first_name; } if (!empty($user_data->last_name)) { $public_display['display_lastname'] = $user_data->last_name; } if (!empty($user_data->first_name) && !empty($user_data->last_name)) { $public_display['display_firstlast'] = $user_data->first_name . ' ' . $user_data->last_name; $public_display['display_lastfirst'] = $user_data->last_name . ' ' . $user_data->first_name; } if (!in_array($user_data->display_name, $public_display)) { // Only add this if it isn't duplicated elsewhere $public_display = array('display_displayname' => $user_data->display_name) + $public_display; } $public_display = array_map('trim', $public_display); $public_display = array_unique($public_display); $output = '<label for="display_name">' . $item_title . $error_mark . '</label>'; $output .= '<select class="default_field_display-name" name="display_name" id="display-name">'; foreach ($public_display as $display_name_option) { $output .= '<option ' . selected($user_data->display_name, $display_name_option, false) . '>' . $display_name_option . '</option>'; } $output .= '</select>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } return apply_filters('wppb_' . $form_location . '_display-name', $output, $form_location, $field, $user_id, $field_check_errors, $request_data); }
function wppb_password_repeat_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { $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'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'default_field_' . $field['id'] . '_description_translation', $field['description']); if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="passw2">' . $item_title . $error_mark . '</label> <input class="text-input" name="passw2" maxlength="' . apply_filters('wppb_maximum_character_length', 70) . '" type="password" id="passw2" value="" autocomplete="off" />'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } return apply_filters('wppb_' . $form_location . '_repeat_password', $output, $form_location, $field, $user_id, $field_check_errors, $request_data); }
function wppb_phone_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Phone') { wp_enqueue_script('wppb-jquery-inputmask', WPPB_PLUGIN_URL . 'front-end/extra-fields/phone/jquery.inputmask.bundle.min.js', array('jquery'), PROFILE_BUILDER_VERSION, true); wp_enqueue_script('wppb-phone-script', WPPB_PLUGIN_URL . 'front-end/extra-fields/phone/script-phone.js', array('wppb-jquery-inputmask'), PROFILE_BUILDER_VERSION, true); $phone_data = json_encode(array('phone_data' => wppb_make_phone_number_format($field, $request_data))); $item_title = apply_filters('wppb_' . $form_location . '_phone_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'register') { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : $field['default-value']; } else { $input_value = isset($field['default-value']) ? trim($field['default-value']) : ''; } $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value; $phone_format_description = __('Required phone number format: ', 'profile-builder') . $field['phone-format'] . '<br>'; $phone_format_description = apply_filters('wppb_phone_format_description', $phone_format_description); if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label> <input data-phone-format="' . esc_attr($phone_data) . '" class="extra_field_phone ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70, $field) . '" type="text" id="' . $field['meta-name'] . '" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/>'; if (!empty($field['phone-format']) || !empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . (!empty($field['phone-format']) ? $phone_format_description : '') . (!empty($item_description) ? $item_description : '') . '</span>'; } } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td> <input data-phone-format="' . esc_attr($phone_data) . '" class="custom_field_phone" size="45" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70, $field) . '" type="text" id="' . $field['meta-name'] . '" value="' . esc_attr($input_value) . '" ' . $extra_attr . '/> <span class="description">' . (!empty($field['phone-format']) ? $phone_format_description : '') . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_phone_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_wysiwyg_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'WYSIWYG') { $item_title = apply_filters('wppb_' . $form_location . '_wysiwyg_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); if ($form_location != 'register') { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : $field['default-content']; } else { $input_value = isset($field['default-content']) ? trim($field['default-content']) : ''; } $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value; if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>'; ob_start(); wp_editor(stripcslashes($input_value), $field['meta-name'], array('textarea_rows' => $field['row-count'], 'textarea_name' => $field['meta-name'], 'editor_class' => 'custom_field_wysiwyg')); $out1 = ob_get_clean(); $output .= $out1; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td>'; ob_start(); wp_editor($input_value, $field['meta-name'], array('textarea_rows' => $field['row-count'], 'textarea_name' => $field['meta-name'], 'editor_class' => 'custom_field_wysiwyg')); $out1 = ob_get_clean(); $output .= $out1; $output .= '<span class="description">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_wysiwyg_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_hidden_input_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Input (Hidden)') { $item_title = apply_filters('wppb_' . $form_location . '_hidden_input_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'register') { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : $field['default-value']; } else { $input_value = isset($field['default-value']) ? trim($field['default-value']) : ''; } $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value; if (apply_filters('wppb_display_capability_level', current_user_can('manage_options'))) { $input_type = 'text'; $hidden_start = $hidden_end = ''; } else { $input_type = 'hidden'; $hidden_start = '<!--'; $hidden_end = '-->'; } if ($form_location != 'back_end') { $output = $hidden_start . ' <label for="' . $field['meta-name'] . '">' . $item_title . '</label>' . $hidden_end . ' <input class="extra_field_hidden_input" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70) . '" type="' . $input_type . '" id="' . $field['meta-name'] . '" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/> ' . $hidden_start . '<span class="wppb-description-delimiter">' . $item_description . '</span>' . $hidden_end; } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = $hidden_start . ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td>' . $hidden_end . ' <input class="custom_field_hidden_input" size="45" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70) . '" type="' . $input_type . '" id="' . $field['meta-name'] . '" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/> ' . $hidden_start . '<span class="description">' . $item_description . '</span> </td> </tr> </table>' . $hidden_end; } return apply_filters('wppb_' . $form_location . '_hidden_input_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_input_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Input') { $item_title = apply_filters('wppb_' . $form_location . '_input_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'register') { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : $field['default-value']; } else { $input_value = isset($field['default-value']) ? trim($field['default-value']) : ''; } $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value; if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label> <input class="extra_field_input ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70, $field) . '" type="text" id="' . $field['meta-name'] . '" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td> <input class="custom_field_input" size="45" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70, $field) . '" type="text" id="' . $field['meta-name'] . '" value="' . esc_attr($input_value) . '" ' . $extra_attr . '/> <span class="description">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_input_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_validation_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Validation') { $item_title = apply_filters('wppb_' . $form_location . '_validation_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : ''; if ($form_location == 'register') { $error_mark = '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>'; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label> <input class="extra_field_input ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70, $field) . '" type="text" id="' . $field['meta-name'] . '" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } return apply_filters('wppb_' . $form_location . '_validation_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_username_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { $item_title = apply_filters('wppb_' . $form_location . '_username_item_title', wppb_icl_t('plugin profile-builder-pro', 'default_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'default_field_' . $field['id'] . '_description_translation', $field['description']); $input_value = $form_location == 'edit_profile' ? get_the_author_meta('user_login', $user_id) : ''; $input_value = trim($input_value) == '' ? $field['default-value'] : $input_value; $input_value = isset($request_data['username']) ? trim($request_data['username']) : $input_value; if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $readonly = $form_location == 'edit_profile' ? ' disabled="disabled"' : ''; $output = ' <label for="username">' . $item_title . $error_mark . '</label> <input class="text-input default_field_username" name="username" maxlength="' . apply_filters('wppb_maximum_character_length', 70) . '" type="text" id="username" value="' . esc_attr($input_value) . '"' . $readonly . '/>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } return apply_filters('wppb_' . $form_location . '_username', $output, $form_location, $field, $user_id, $field_check_errors, $request_data); }
function wppb_agree_to_terms_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Checkbox (Terms and Conditions)') { if ($form_location == 'register') { $item_title = apply_filters('wppb_' . $form_location . '_toa_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : ''; $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $extra_attr = apply_filters('wppb_extra_attribute', '', $field); $output = ' <label for="' . $field['meta-name'] . '"> <input value="agree" name="' . $field['meta-name'] . '" id="' . $field['meta-name'] . '" type="checkbox" class="custom_field_toa" ' . $extra_attr . ' '; if (isset($input_value) && $input_value == 'agree') { $output .= ' checked="yes"'; } $output .= ' />' . $item_title . $error_mark . '</label>'; $output .= '<span class="agree_to_terms">' . trim(html_entity_decode($item_description)) . '</span>'; return apply_filters('wppb_' . $form_location . '_toa_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } } }
function wppb_front_end_profile_info() { global $changesSaved; global $changesSavedNoMatchingPass; global $changesSavedNoPass; $editProfileFilterArray = array(); $editProfileFilterArray2 = array(); $extraFieldsErrorHolder = array(); //we will use this array to store the ID's of the extra-fields left uncompleted global $wppb_shortcode_on_front; //get "login with" setting $wppb_generalSettings = get_option('wppb_general_settings'); $wppb_shortcode_on_front = true; ob_start(); get_currentuserinfo(); $wppb_defaultOptions = get_option('wppb_default_settings'); $changesSavedNoEmail = 'no'; $changesSavedNoEmailExist = 'no'; $previousError = 'no'; $pictureUpload = 'no'; $avatarUpload = 'yes'; $allRequiredCompleted = 'yes'; $uploadName = array(); $uploadExt = array(); $uploadSize = array(); $editFilterArray = array(); $error = null; /* Get user info. */ global $current_user; /* delete the attachment if set */ if (isset($_GET['userID']) && isset($_GET['field'])) { update_user_meta($_GET['userID'], $_GET['field'], ''); } /* delete the avatar */ if (isset($_GET['userID']) && isset($_GET['fieldOriginal']) && isset($_GET['fieldResized'])) { update_user_meta($_GET['userID'], $_GET['fieldOriginal'], ''); update_user_meta($_GET['userID'], $_GET['fieldResized'], ''); } //fallback if the file was largen then post_max_size, case in which no errors can be saved in $_FILES[fileName]['error'] if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') { $editProfileFilterArray['noPost'] = '<p class="error">' . sprintf(__('The information size you were trying to submit was larger than %1$sb!<br/>This is usually caused by a large file(s) trying to be uploaded.<br/>Since it was also larger than %2$sb no additional information is available.<br/>The user was NOT created!', 'profilebuilder'), WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA, WPPB_SERVER_MAX_POST_SIZE_MEGA) . '</p>'; echo $editProfileFilterArray['noPost'] = apply_filters('wppb_edit_profile_no_post_error', $editProfileFilterArray['noPost']); } //a way to catch the user before updating his/her profile without completing a required field if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'update-user' && wp_verify_nonce($_POST['edit_nonce_field'], 'verify_edit_user')) { //variable to control whether the user submitted data or not $allRequiredCompleted = apply_filters('wppb_edit_profile_all_required_completed', $allRequiredCompleted); if ($wppb_defaultOptions['firstname'] == 'show') { $_POST['first_name'] = apply_filters('wppb_edit_profile_posted_first_name_check', $_POST['first_name']); if ($wppb_defaultOptions['firstnameRequired'] == 'yes') { if (isset($_POST['first_name']) && trim($_POST['first_name']) == '') { $allRequiredCompleted = 'no'; } } } if ($wppb_defaultOptions['lastname'] == 'show') { $_POST['last_name'] = apply_filters('wppb_edit_profile_posted_last_name_check', $_POST['last_name']); if ($wppb_defaultOptions['lastnameRequired'] == 'yes') { if (isset($_POST['last_name']) && trim($_POST['last_name']) == '') { $allRequiredCompleted = 'no'; } } } if ($wppb_defaultOptions['nickname'] == 'show') { $_POST['nickname'] = apply_filters('wppb_edit_profile_posted_nickname_check', $_POST['nickname']); if ($wppb_defaultOptions['nicknameRequired'] == 'yes') { if (isset($_POST['nickname']) && trim($_POST['nickname']) == '') { $allRequiredCompleted = 'no'; } } } if ($wppb_defaultOptions['dispname'] == 'show') { $_POST['display_name'] = apply_filters('wppb_edit_profile_posted_display_name_check', $_POST['display_name']); if ($wppb_defaultOptions['dispnameRequired'] == 'yes') { if (isset($_POST['display_name']) && trim($_POST['display_name']) == '') { $allRequiredCompleted = 'no'; } } } if ($wppb_defaultOptions['website'] == 'show') { $_POST['website'] = apply_filters('wppb_edit_profile_posted_website_check', $_POST['website']); if ($wppb_defaultOptions['websiteRequired'] == 'yes') { if (isset($_POST['website']) && trim($_POST['website']) == '') { $allRequiredCompleted = 'no'; } } } if ($wppb_defaultOptions['aim'] == 'show') { $_POST['aim'] = apply_filters('wppb_edit_profile_posted_aim_check', $_POST['aim']); if ($wppb_defaultOptions['aimRequired'] == 'yes') { if (isset($_POST['aim']) && trim($_POST['aim']) == '') { $allRequiredCompleted = 'no'; } } } if ($wppb_defaultOptions['yahoo'] == 'show') { $_POST['yim'] = apply_filters('wppb_edit_profile_posted_yahoo_check', $_POST['yim']); if ($wppb_defaultOptions['yahooRequired'] == 'yes') { if (isset($_POST['yim']) && trim($_POST['yim']) == '') { $allRequiredCompleted = 'no'; } } } if ($wppb_defaultOptions['jabber'] == 'show') { $_POST['jabber'] = apply_filters('wppb_edit_profile_posted_jabber_check', $_POST['jabber']); if ($wppb_defaultOptions['jabberRequired'] == 'yes') { if (isset($_POST['jabber']) && trim($_POST['jabber']) == '') { $allRequiredCompleted = 'no'; } } } if ($wppb_defaultOptions['bio'] == 'show') { $_POST['description'] = apply_filters('wppb_edit_profile_posted_bio_check', $_POST['description']); if ($wppb_defaultOptions['bioRequired'] == 'yes') { if (isset($_POST['description']) && trim($_POST['description']) == '') { $allRequiredCompleted = 'no'; } } } /* also check the extra profile information */ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "input": $_POST[$value['item_type'] . $value['id']] = apply_filters('wppb_edit_profile_input_custom_field_' . $value['id'] . '_check', $_POST[$value['item_type'] . $value['id']]); if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); $allRequiredCompleted = 'no'; } } } break; case "checkbox": $checkboxOption = ''; $checkboxValue = explode(',', $value['item_options']); foreach ($checkboxValue as $thisValue) { $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post if (isset($_POST[$thisValue . $value['id']])) { $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue . $value['id']]); $checkboxOption = $checkboxOption . $localValue . ','; } } if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($checkboxOption) == '') { array_push($extraFieldsErrorHolder, $value['id']); $allRequiredCompleted = 'no'; } } } break; case "radio": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); $allRequiredCompleted = 'no'; } } } break; case "select": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); $allRequiredCompleted = 'no'; } } } break; case "countrySelect": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); $allRequiredCompleted = 'no'; } } } break; case "timeZone": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); $allRequiredCompleted = 'no'; } } } break; case "datepicker": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); $allRequiredCompleted = 'no'; } } } break; case "textarea": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); $allRequiredCompleted = 'no'; } } } break; case "upload": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { $uploadedfile = $value['item_type'] . $value['id']; if (basename($_FILES[$uploadedfile]['name']) == '') { array_push($extraFieldsErrorHolder, $value['id']); $allRequiredCompleted = 'no'; } } } break; case "avatar": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { $uploadedfile = $value['item_type'] . $value['id']; if (basename($_FILES[$uploadedfile]['name']) == '') { array_push($extraFieldsErrorHolder, $value['id']); $allRequiredCompleted = 'no'; } } } break; } } } $allRequiredCompleted = apply_filters('wppb_edit_profile_all_required_completed_after_check', $allRequiredCompleted); } /* If profile was saved, update profile. */ if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'update-user' && wp_verify_nonce($_POST['edit_nonce_field'], 'verify_edit_user') && $allRequiredCompleted == 'yes') { if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { } else { $_POST['email'] = apply_filters('wppb_edit_profile_posted_email', $_POST['email']); if ($wppb_defaultOptions['emailRequired'] == 'yes') { if (trim($_POST['email']) != '' && isset($_POST['email'])) { if (email_exists($_POST['email']) != FALSE) { $thisEmail = email_exists($_POST['email']); } else { $thisEmail = $current_user->id; } if (!empty($_POST['email']) && is_email($_POST['email'])) { // if the user entered a valid email address if ($thisEmail == $current_user->id) { // if the entered email address is not already registered to some other user wp_update_user(array('ID' => $current_user->id, 'user_email' => esc_attr($_POST['email']))); $changesSaved = 'yes'; } else { $changesSavedNoEmailExist = 'yes'; } } else { $changesSavedNoEmail = 'yes'; } } } else { if (email_exists($_POST['email']) != FALSE) { $thisEmail = email_exists($_POST['email']); } else { $thisEmail = $current_user->id; } if (!empty($_POST['email']) && is_email($_POST['email'])) { // if the user entered a valid email address if ($thisEmail == $current_user->id) { // if the entered email address is not already registered to some other user wp_update_user(array('ID' => $current_user->id, 'user_email' => esc_attr($_POST['email']))); $changesSaved = 'yes'; } else { $changesSavedNoEmailExist = 'yes'; } } else { $changesSavedNoEmail = 'yes'; } } } /* Update user information. */ if ($wppb_defaultOptions['firstname'] == 'show') { $_POST['first_name'] = apply_filters('wppb_edit_profile_posted_first_name', $_POST['first_name']); if ($wppb_defaultOptions['firstnameRequired'] == 'yes') { if (isset($_POST['first_name']) && trim($_POST['first_name']) != '') { wp_update_user(array('ID' => $current_user->id, 'first_name' => esc_attr($_POST['first_name']))); $changesSaved = 'yes'; } } else { wp_update_user(array('ID' => $current_user->id, 'first_name' => esc_attr($_POST['first_name']))); $changesSaved = 'yes'; } } if ($wppb_defaultOptions['lastname'] == 'show') { $_POST['last_name'] = apply_filters('wppb_edit_profile_posted_last_name', $_POST['last_name']); if ($wppb_defaultOptions['lastnameRequired'] == 'yes') { if (isset($_POST['last_name']) && trim($_POST['last_name']) != '') { wp_update_user(array('ID' => $current_user->id, 'last_name' => esc_attr($_POST['last_name']))); $changesSaved = 'yes'; } } else { wp_update_user(array('ID' => $current_user->id, 'last_name' => esc_attr($_POST['last_name']))); $changesSaved = 'yes'; } } if ($wppb_defaultOptions['nickname'] == 'show') { $_POST['nickname'] = apply_filters('wppb_edit_profile_posted_nickname', $_POST['nickname']); if ($wppb_defaultOptions['nicknameRequired'] == 'yes') { if (isset($_POST['nickname']) && trim($_POST['nickname']) != '') { wp_update_user(array('ID' => $current_user->id, 'nickname' => esc_attr($_POST['nickname']))); $changesSaved = 'yes'; } } else { wp_update_user(array('ID' => $current_user->id, 'nickname' => esc_attr($_POST['nickname']))); $changesSaved = 'yes'; } } if ($wppb_defaultOptions['dispname'] == 'show') { $_POST['display_name'] = apply_filters('wppb_edit_profile_posted_display_name', $_POST['display_name']); if ($wppb_defaultOptions['dispnameRequired'] == 'yes') { if (isset($_POST['display_name']) && trim($_POST['display_name']) != '') { wp_update_user(array('ID' => $current_user->id, 'display_name' => esc_attr($_POST['display_name']))); $changesSaved = 'yes'; } } else { wp_update_user(array('ID' => $current_user->id, 'display_name' => esc_attr($_POST['display_name']))); $changesSaved = 'yes'; } } if ($wppb_defaultOptions['website'] == 'show') { $_POST['website'] = apply_filters('wppb_edit_profile_posted_website', $_POST['website']); if ($wppb_defaultOptions['websiteRequired'] == 'yes') { if (isset($_POST['website']) && trim($_POST['website']) != '') { $wppbPos = strpos((string) $_POST['website'], 'http://'); if ($wppbPos !== FALSE) { wp_update_user(array('ID' => $current_user->id, 'user_url' => esc_attr($_POST['website']))); $changesSaved = 'yes'; } else { wp_update_user(array('ID' => $current_user->id, 'user_url' => 'http://' . esc_attr($_POST['website']))); $changesSaved = 'yes'; } } } else { $wppbPos = strpos((string) $_POST['website'], 'http://'); $website = esc_attr($_POST['website']); if ($wppbPos !== FALSE) { if ($website == 'http://') { $website = ''; } wp_update_user(array('ID' => $current_user->id, 'user_url' => $website)); $changesSaved = 'yes'; } else { if ($website != '') { $website = 'http://' . $website; } wp_update_user(array('ID' => $current_user->id, 'user_url' => $website)); $changesSaved = 'yes'; } } } if ($wppb_defaultOptions['aim'] == 'show') { $_POST['aim'] = apply_filters('wppb_edit_profile_posted_aim', $_POST['aim']); if ($wppb_defaultOptions['aimRequired'] == 'yes') { if (isset($_POST['aim']) && trim($_POST['aim']) != '') { update_user_meta($current_user->id, 'aim', esc_attr($_POST['aim'])); $changesSaved = 'yes'; } } else { update_user_meta($current_user->id, 'aim', esc_attr($_POST['aim'])); $changesSaved = 'yes'; } } if ($wppb_defaultOptions['yahoo'] == 'show') { $_POST['yim'] = apply_filters('wppb_edit_profile_posted_yahoo', $_POST['yim']); if ($wppb_defaultOptions['yahooRequired'] == 'yes') { if (isset($_POST['yim']) && trim($_POST['yim']) != '') { update_user_meta($current_user->id, 'yim', esc_attr($_POST['yim'])); $changesSaved = 'yes'; } } else { update_user_meta($current_user->id, 'yim', esc_attr($_POST['yim'])); $changesSaved = 'yes'; } } if ($wppb_defaultOptions['jabber'] == 'show') { $_POST['jabber'] = apply_filters('wppb_edit_profile_posted_jabber', $_POST['jabber']); if ($wppb_defaultOptions['jabberRequired'] == 'yes') { if (isset($_POST['jabber']) && trim($_POST['jabber']) != '') { update_user_meta($current_user->id, 'jabber', esc_attr($_POST['jabber'])); $changesSaved = 'yes'; } } else { update_user_meta($current_user->id, 'jabber', esc_attr($_POST['jabber'])); $changesSaved = 'yes'; } } if ($wppb_defaultOptions['bio'] == 'show') { $_POST['description'] = apply_filters('wppb_edit_profile_posted_bio', $_POST['description']); if ($wppb_defaultOptions['bioRequired'] == 'yes') { if (isset($_POST['description']) && trim($_POST['description']) != '') { update_user_meta($current_user->id, 'description', esc_attr($_POST['description'])); $changesSaved = 'yes'; } } else { update_user_meta($current_user->id, 'description', esc_attr($_POST['description'])); $changesSaved = 'yes'; } } /* update the extra profile information */ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "input": $_POST[$value['item_type'] . $value['id']] = apply_filters('wppb_edit_profile_input_custom_field_' . $value['id'], $_POST[$value['item_type'] . $value['id']]); if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) != '') { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } else { array_push($extraFieldsErrorHolder, $value['id']); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } break; case "hiddenInput": update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "checkbox": $checkboxOption = ''; $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']); $checkboxValue = explode(',', $value['item_options']); foreach ($checkboxValue as $thisValue) { $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post if (isset($_POST[$thisValue . $value['id']])) { $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue . $value['id']]); $checkboxOption = $checkboxOption . $localValue . ','; } } if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($checkboxOption) != '') { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($checkboxOption)); } else { array_push($extraFieldsErrorHolder, $value['id']); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($checkboxOption)); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($checkboxOption)); } break; case "radio": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) != '') { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } else { array_push($extraFieldsErrorHolder, $value['id']); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } break; case "select": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) != '') { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } else { array_push($extraFieldsErrorHolder, $value['id']); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } break; case "countrySelect": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) != '') { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } else { array_push($extraFieldsErrorHolder, $value['id']); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } break; case "timeZone": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) != '') { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } else { array_push($extraFieldsErrorHolder, $value['id']); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } break; case "datepicker": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) != '') { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } else { array_push($extraFieldsErrorHolder, $value['id']); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } break; case "textarea": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) != '') { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } else { array_push($extraFieldsErrorHolder, $value['id']); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } } else { update_user_meta($current_user->id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); } break; case "upload": $uploadedfile = $value['item_type'] . $value['id']; //get allowed file types if ($value['item_options'] != NULL || $value['item_options'] != '') { $allFiles = false; $extensions = explode(',', $value['item_options']); foreach ($extensions as $key3 => $value3) { $extensions[$key3] = trim($value3); } } else { $allFiles = true; } //first we need to verify if we don't try to upload a 0b or 0 length file if (basename($_FILES[$uploadedfile]['name']) != '') { //get this attachments extension $thisFileExtStart = strrpos($_FILES[$uploadedfile]['name'], '.'); $thisFileExt = substr($_FILES[$uploadedfile]['name'], $thisFileExtStart); if ($allFiles === false) { if (in_array($thisFileExt, $extensions)) { //second we need to verify if the uploaded file size is less then the set file size in php.ini if ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0) { //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error $fileName = basename($_FILES[$uploadedfile]['name']); $finalFileName = ''; for ($i = 0; $i < strlen($fileName); $i++) { if ($fileName[$i] == "'") { $finalFileName .= '`'; } else { $finalFileName .= $fileName[$i]; } } //create the target path for uploading $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $target_path = $wpUploadPath['basedir'] . "/profile_builder/attachments/"; $target_path = $target_path . 'userID_' . $current_user->id . '_attachment_' . $finalFileName; if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) { $upFile = $wpUploadPath['baseurl'] . '/profile_builder/attachments/userID_' . $current_user->id . '_attachment_' . $finalFileName; update_user_meta($current_user->id, $value['item_metaName'], $upFile); $pictureUpload = 'yes'; } else { //insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded array_push($uploadName, basename($_FILES[$uploadedfile]['name'])); } } else { //insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded array_push($uploadName, basename($_FILES[$uploadedfile]['name'])); } } else { array_push($uploadExt, basename($_FILES[$uploadedfile]['name'])); $allowedExtensions = ''; (int) ($nrOfExt = count($extensions) - 2); foreach ($extensions as $key4 => $value4) { $allowedExtensions .= $value4; if ($key4 <= $nrOfExt) { $allowedExtensions .= ', '; } } } } else { //second we need to verify if the uploaded file size is less then the set file size in php.ini if ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0) { //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error $fileName = basename($_FILES[$uploadedfile]['name']); $finalFileName = ''; for ($i = 0; $i < strlen($fileName); $i++) { if ($fileName[$i] == "'") { $finalFileName .= '`'; } else { $finalFileName .= $fileName[$i]; } } //create the target path for uploading $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $target_path = $wpUploadPath['basedir'] . "/profile_builder/attachments/"; $target_path = $target_path . 'userID_' . $current_user->id . '_attachment_' . $finalFileName; if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) { $upFile = $wpUploadPath['baseurl'] . '/profile_builder/attachments/userID_' . $current_user->id . '_attachment_' . $finalFileName; update_user_meta($current_user->id, $value['item_metaName'], $upFile); $pictureUpload = 'yes'; } else { //insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded array_push($uploadName, basename($_FILES[$uploadedfile]['name'])); } } else { //insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded array_push($uploadName, basename($_FILES[$uploadedfile]['name'])); } } } break; case "avatar": $avatarUpload = 'no'; $uploadedfile = $value['item_type'] . $value['id']; $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $target_path_original = $wpUploadPath['basedir'] . "/profile_builder/avatars/"; $fileName = $_FILES[$uploadedfile]['name']; $finalFileName = ''; for ($i = 0; $i < strlen($fileName); $i++) { if ($fileName[$i] == "'") { $finalFileName .= '`'; } elseif ($fileName[$i] == ' ') { $finalFileName .= '_'; } else { $finalFileName .= $fileName[$i]; } } $fileName = $finalFileName; $target_path = $target_path_original . 'userID_' . $current_user->id . '_originalAvatar_' . $fileName; /* when trying to upload file, be sure it's one of the accepted image file-types */ if (($_FILES[$uploadedfile]['type'] == 'image/jpeg' || $_FILES[$uploadedfile]['type'] == 'image/jpg' || $_FILES[$uploadedfile]['type'] == 'image/png' || $_FILES[$uploadedfile]['type'] == 'image/bmp' || $_FILES[$uploadedfile]['type'] == 'image/pjpeg' || $_FILES[$uploadedfile]['type'] == 'image/x-png') && ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0)) { $avatarUpload = 'yes'; $wp_filetype = wp_check_filetype(basename($_FILES[$uploadedfile]['name']), null); $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $fileName, 'post_content' => '', 'post_status' => 'inherit'); $attach_id = wp_insert_attachment($attachment, $target_path); $upFile = image_downsize($attach_id, 'thumbnail'); $upFile = $upFile[0]; //if file upload succeded if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) { update_user_meta($current_user->id, $value['item_metaName'], $upFile); update_user_meta($current_user->id, 'resized_avatar_' . $value['id'], ''); } else { $avatarUpload = 'no'; } } elseif (($_FILES[$uploadedfile]['size'] > WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE || $_FILES[$uploadedfile]['size'] == 0) && $fileName != '') { $avatarUpload = 'no'; } elseif ($fileName == '') { $avatarUpload = 'yes'; } break; } } } } ?> <div class="wppb_holder" id="wppb_modify"> <?php if (!is_user_logged_in()) { $editProfileFilterArray['notLoggedIn'] = ' <p class="warning">' . __('You must be logged in to edit your profile.', 'profilebuilder') . '</p><!-- .warning -->'; echo $editProfileFilterArray['notLoggedIn'] = apply_filters('wppb_edit_profile_user_not_logged_in', $editProfileFilterArray['notLoggedIn']); } else { /* messages for the the delete avatar/attachment */ if (isset($_GET['fileType'])) { if ($_GET['fileType'] == 'avatar') { $editProfileFilterArray['avatarChangesSaved'] = ' <p class="changes-saved">' . __('The avatar was successfully deleted.', 'profilebuilder') . '</p><!-- .changes-saved -->'; echo $editProfileFilterArray['avatarChangesSaved'] = apply_filters('wppb_edit_profile_avatar_changes_saved', $editProfileFilterArray['avatarChangesSaved']); unset($_GET['fileType']); } elseif ($_GET['fileType'] == 'attachment') { $editProfileFilterArray['attachmentChangesSaved'] = '<p class="changes-saved">' . sprintf(__('The attachment "%1$s" was successfully deleted.', 'profilebuilder'), $_GET['fileName']) . '</p><!-- .changes-saved -->'; echo $editProfileFilterArray['attachmentChangesSaved'] = apply_filters('wppb_edit_profile_attachment_changes_saved', $editProfileFilterArray['attachmentChangesSaved']); unset($_GET['fileType']); unset($_GET['fileName']); } } /* all the other messages/errors */ $nrOfBadUploads = 0; $nrOfBadUploads = count($uploadName); $nrOfBadExtUploads = count($uploadExt); if ($changesSaved == 'yes' && $changesSavedNoMatchingPass == 'no' && $changesSavedNoPass == 'no' && $changesSavedNoEmail == 'no' && $changesSavedNoEmailExist == 'no' && $avatarUpload == 'yes' && $nrOfBadUploads == 0 && $nrOfBadExtUploads == 0) { $editProfileFilterArray['allChangesSaved'] = ' <p class="changes-saved">' . __('The changes have been successfully saved.', 'profilebuilder') . '</p><!-- .changes-saved -->'; echo $editProfileFilterArray['allChangesSaved'] = apply_filters('wppb_edit_profile_all_changes_saved', $editProfileFilterArray['allChangesSaved']); } elseif ($changesSaved == 'yes' && $changesSavedNoEmailExist == 'yes' && $previousError == 'no') { $editProfileFilterArray['allChangesSavedExceptExistingEmail'] = '<p class="semi-saved">' . sprintf(__('The email address you entered is already registered to a different user.%1$sThe email address was %2$sNOT%3$s updated along with the rest of the information.', 'profilebuilder'), '<br/>', '<span class="error">', '</span>') . '</p>'; echo $editProfileFilterArray['allChangesSavedExceptExistingEmail'] = apply_filters('wppb_edit_profile_all_changes_saved_except_existing_email', $editProfileFilterArray['allChangesSavedExceptExistingEmail']); $previousError = 'yes'; } elseif ($changesSaved == 'yes' && $changesSavedNoEmail == 'yes' && $previousError == 'no') { $editProfileFilterArray['allChangesSavedExceptInvalidEmail'] = '<p class="semi-saved">' . sprintf(__('The email address you entered is invalid.%1$sThe email address was %2$sNOT%3$s updated along with the rest of the information.', 'profilebuilder'), '<br/>', '<span class="error">', '</span>') . '</p>'; echo $editProfileFilterArray['allChangesSavedExceptInvalidEmail'] = apply_filters('wppb_edit_profile_all_changes_saved_except_invalid_email', $editProfileFilterArray['allChangesSavedExceptInvalidEmail']); $previousError = 'yes'; } elseif ($changesSaved == 'yes' && $changesSavedNoMatchingPass == 'yes' && $previousError == 'no') { $editProfileFilterArray['allChangesSavedMismatchedPass'] = '******' . sprintf(__('The passwords you entered do not match.%1$sThe password was %2$sNOT%3$s updated along with the rest of the information.', 'profilebuilder'), '<br/>', '<span class="error">', '</span>') . '</p>'; echo $editProfileFilterArray['allChangesSavedMismatchedPass'] = apply_filters('wppb_edit_profile_all_changes_saved_except_mismatch_password', $editProfileFilterArray['allChangesSavedMismatchedPass']); $previousError = 'yes'; } elseif ($changesSaved == 'yes' && $changesSavedNoPass == 'yes' && $previousError == 'no') { $editProfileFilterArray['allChangesSavedUncompletedPass'] = '******' . sprintf(__('You didn\'t complete both password fields.%1$sThe password was %2$sNOT%3$s updated along with the rest of the information.', 'profilebuilder'), '<br/>', '<span class="error">', '</span>') . '</p>'; echo $editProfileFilterArray['allChangesSavedUncompletedPass'] = apply_filters('wppb_edit_profile_all_changes_saved_except_uncompleted_password', $editProfileFilterArray['allChangesSavedUncompletedPass']); $previousError = 'yes'; } elseif ($allRequiredCompleted == 'no') { $editProfileFilterArray['errorSavingChanges'] = '<p class="error">' . $errorMessage . '<br/>' . __('Your profile was NOT updated, since not all required fields were completed!', 'profilebuilder') . '</p><!-- .error -->'; echo $editProfileFilterArray['errorSavingChanges'] = apply_filters('wppb_edit_profile_error_saving_changes', $editProfileFilterArray['errorSavingChanges']); } $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { if ($changesSaved == 'yes' && $nrOfBadUploads > 0 && $previousError == 'no') { $lastOne = 0; $editProfileFilterArray['errorUploadingAttachments'] = ' <p class="semi-saved">' . __('There was an error while trying to upload the following attachments:', 'profilebuilder') . '<br/> <span class="error">'; foreach ($uploadName as $key => $name) { $lastOne++; $editProfileFilterArray['errorUploadingAttachments'] .= $name; if ($nrOfBadUploads - $lastOne > 0) { $editProfileFilterArray['errorUploadingAttachments'] .= ';<span style="padding-left:10px"></span>'; } } $editProfileFilterArray['errorUploadingAttachments'] .= '</span><br/>' . sprintf(__('Possible cause: the size was bigger than %1$sb. The listed attachements were %2$sNOT%3$s updated along with the rest of the information.', 'profilebuilder'), WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA, '<span class="error">', '</span>') . '</p>'; echo $editProfileFilterArray['errorUploadingAttachments'] = apply_filters('wppb_edit_profile_error_uploading_attachments', $editProfileFilterArray['errorUploadingAttachments']); $previousError = 'yes'; } if ($changesSaved == 'yes' && $avatarUpload == 'no' && $previousError == 'no') { $editProfileFilterArray['errorUploadingAvatar'] = ' <p class="semi-saved">' . __('There was an error while trying to upload your avatar picture.', 'profilebuilder') . '<br/>' . __('Possible cause: size/incorrect file-type.', 'profilebuilder') . '<br/>' . __('The avatar was', 'profilebuilder') . ' <span class="error">' . __('NOT', 'profilebuilder') . '</span> ' . __('updated along with the rest of the information.', 'profilebuilder') . ' </p>'; echo $editProfileFilterArray['errorUploadingAvatar'] = apply_filters('wppb_edit_profile_error_uploading_avatar', $editProfileFilterArray['errorUploadingAvatar']); $previousError = 'yes'; } elseif ($changesSaved == 'yes' && $nrOfBadExtUploads != 0 && $previousError == 'no') { $editProfileFilterArray['errorUploadingAttachmentExts'] = ' <p class="semi-saved">' . __('There was an error while trying to upload the following attachment(s)', 'profilebuilder') . ': <span class="error">'; foreach ($uploadExt as $key5 => $name5) { $lastOne++; $editProfileFilterArray['errorUploadingAttachmentExts'] .= $name5; if ($nrOfBadExtUploads - $lastOne > 0) { $editProfileFilterArray['errorUploadingAttachmentExts'] .= ';<span style="padding-left:10px"></span>'; } } $editProfileFilterArray['errorUploadingAttachmentExts'] .= '</span><br/>' . sprintf(__('Only files with the following extension(s) can be uploaded: %1$s<br/>This file was %2$sNOT%3$s updated along with the rest of the information.', 'profilebuilder'), '<span class="error">' . $allowedExtensions . '</span>', '<span class="error">', '</span>') . '</p>'; echo $editProfileFilterArray['errorUploadingAttachmentExts'] = apply_filters('wppb_edit_profile_error_uploading_attachment', $editProfileFilterArray['errorUploadingAttachmentExts']); $previousError = 'yes'; } } /* use this action hook to add extra content before the edit profile form. */ do_action('wppb_before_edit_profile_fields'); ?> <form enctype="multipart/form-data" method="post" id="edituser" class="user-forms" action="<?php wppb_curpageurl(); ?> "> <?php echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE . '" /><!-- set the MAX_FILE_SIZE to the server\'s current max upload size in bytes -->'; $editProfileFilterArray2['contentName1'] = '<p class="nameHeader"><strong>' . __('Name', 'profilebuilder') . '</strong></p>'; $editProfileFilterArray2['contentName1'] = apply_filters('wppb_edit_profile_content_name1', $editProfileFilterArray2['contentName1']); if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { if ($wppb_defaultOptions['email'] == 'show') { $editProfileFilterArray2['contentName2'] = ' <p class="email"> <label for="email">' . __('Email', 'profilebuilder') . '</label> <input class="text-input" name="email" type="text" id="email" value="' . get_the_author_meta('user_email', $current_user->id) . '" disabled="disabled"/> <span class="wppb-description-delimiter"> ' . __('The email cannot be changed.', 'profilebuilder') . '</span> </p><!-- .first_name -->'; $editProfileFilterArray2['contentName2'] = apply_filters('wppb_edit_profile_content_name2_with_email', $editProfileFilterArray2['contentName2'], $current_user->id); } } else { if ($wppb_defaultOptions['username'] == 'show') { $editProfileFilterArray2['contentName2'] = ' <p class="username"> <label for="user_login">' . __('Username', 'profilebuilder') . '</label> <input class="text-input" name="user_login" type="text" id="user_login" value="' . get_the_author_meta('user_login', $current_user->id) . '" disabled="disabled"/> <span class="wppb-description-delimiter"> ' . __('The usernames cannot be changed.', 'profilebuilder') . '</span> </p><!-- .first_name -->'; $editProfileFilterArray2['contentName2'] = apply_filters('wppb_edit_profile_content_name2', $editProfileFilterArray2['contentName2'], $current_user->id); } } if ($wppb_defaultOptions['firstname'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['firstnameRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; if (isset($_POST['first_name'])) { if (trim($_POST['first_name']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator.', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $editProfileFilterArray2['contentName3'] = ' <p class="first_name' . $errorVar . '"> <label for="first_name">' . __('First Name', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="first_name" type="text" id="first_name" value="' . get_the_author_meta('first_name', $current_user->id) . '" /> </p><!-- .first_name -->'; $editProfileFilterArray2['contentName3'] = apply_filters('wppb_edit_profile_content_name3', $editProfileFilterArray2['contentName3'], $current_user->id, $errorVar, $errorMark); } if ($wppb_defaultOptions['lastname'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['lastnameRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; if (isset($_POST['last_name'])) { if (trim($_POST['last_name']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator.', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $editProfileFilterArray2['contentName4'] = ' <p class="last_name' . $errorVar . '"> <label for="last_name">' . __('Last Name', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="last_name" type="text" id="last_name" value="' . get_the_author_meta('last_name', $current_user->id) . '" /> </p><!-- .last_name -->'; $editProfileFilterArray2['contentName4'] = apply_filters('wppb_edit_profile_content_name4', $editProfileFilterArray2['contentName4'], $current_user->id); } if ($wppb_defaultOptions['nickname'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['nicknameRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; if (isset($_POST['nickname'])) { if (trim($_POST['nickname']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator.', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $editProfileFilterArray2['contentName5'] = ' <p class="nickname' . $errorVar . '"> <label for="nickname">' . __('Nickname', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="nickname" type="text" id="nickname" value="' . get_the_author_meta('nickname', $current_user->id) . '" /> </p><!-- .nickname -->'; $editProfileFilterArray2['contentName5'] = apply_filters('wppb_edit_profile_content_name5', $editProfileFilterArray2['contentName5'], $current_user->id, $errorVar, $errorMark); } if ($wppb_defaultOptions['dispname'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['dispnameRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; if (isset($_POST['display_name'])) { if (trim($_POST['display_name']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator.', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $editProfileFilterArray2['displayName'] = ' <p class="display_name' . $errorVar . '"> <label for="display_name">' . __('Display name publicly as', 'profilebuilder') . $errorMark . '</label> <select name="display_name" id="display_name">'; $public_display = array(); $public_display['display_username'] = get_the_author_meta('user_login', $current_user->id); $thisFirstName = get_the_author_meta('first_name', $current_user->id); if (!empty($thisFirstName)) { $public_display['display_firstname'] = get_the_author_meta('first_name', $current_user->id); } $thisLastName = get_the_author_meta('last_name', $current_user->id); if (!empty($thisLastName)) { $public_display['display_lastname'] = get_the_author_meta('last_name', $current_user->id); } $public_display['display_nickname'] = get_the_author_meta('nickname', $current_user->id); if (!empty($thisFirstName) && !empty($thisLastName)) { $public_display['display_firstlast'] = $thisFirstName . ' ' . $thisLastName; $public_display['display_lastfirst'] = $thisLastName . ' ' . $thisFirstName; } $thisDisplayName = get_the_author_meta('display_name', $current_user->id); if (!in_array($thisDisplayName, $public_display)) { // Only add this if it isn't duplicated elsewhere $public_display = array('display_displayname' => $thisDisplayName) + $public_display; } $public_display = array_map('trim', $public_display); foreach ($public_display as $id => $item) { $editProfileFilterArray2['displayName'] .= '<option id="' . $id . '" value="' . $item . '"'; if ($thisDisplayName == $item) { $editProfileFilterArray2['displayName'] .= ' selected'; } $editProfileFilterArray2['displayName'] .= '>' . $item . '</option>'; } $editProfileFilterArray2['displayName'] .= ' </select> </p><!-- .display_name -->'; $editProfileFilterArray2['displayName'] = apply_filters('wppb_edit_profile_display_name', $editProfileFilterArray2['displayName'], $current_user->id, $errorVar, $errorMark); } $editProfileFilterArray2['contentInfo1'] = '<p class="contactInfoHeader"><strong>' . __('Contact Info', 'profilebuilder') . '</strong></p>'; $editProfileFilterArray2['contentInfo1'] = apply_filters('wppb_edit_profile_content_info1', $editProfileFilterArray2['contentInfo1']); if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { } else { if ($wppb_defaultOptions['email'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['emailRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; if (isset($_POST['email'])) { if (trim($_POST['email']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator.', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $editProfileFilterArray2['contentInfo2'] = ' <p class="form-email' . $errorVar . '"> <label for="email">' . __('E-mail', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="email" type="text" id="email" value="' . get_the_author_meta('user_email', $current_user->id) . '" /> <span class="wppb-description-delimiter">' . __('(required)', 'profilebuilder') . '</span> </p><!-- .form-email -->'; $editProfileFilterArray2['contentInfo2'] = apply_filters('wppb_edit_profile_content_info2', $editProfileFilterArray2['contentInfo2'], $current_user->id, $errorVar, $errorMark); } } if ($wppb_defaultOptions['website'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['websiteRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; if (isset($_POST['website']) && trim($_POST['website']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator.', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } $editProfileFilterArray2['contentInfo3'] = ' <p class="form-website' . $errorVar . '"> <label for="website">' . __('Website', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="website" type="text" id="website" value="' . get_the_author_meta('user_url', $current_user->id) . '" /> </p><!-- .form-website -->'; $editProfileFilterArray2['contentInfo3'] = apply_filters('wppb_edit_profile_content_info3', $editProfileFilterArray2['contentInfo3'], $current_user->id, $errorVar, $errorMark); } if ($wppb_defaultOptions['aim'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['aimRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; if (isset($_POST['aim']) && trim($_POST['aim']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator.', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } $editProfileFilterArray2['contentInfo4'] = ' <p class="form-aim' . $errorVar . '"> <label for="aim">' . __('AIM', 'profilebuilder') . '</label> <input class="text-input" name="aim" type="text" id="aim" value="' . get_the_author_meta('aim', $current_user->id) . '" /> </p><!-- .form-aim -->'; $editProfileFilterArray2['contentInfo4'] = apply_filters('wppb_edit_profile_content_info4', $editProfileFilterArray2['contentInfo4'], $current_user->id, $errorVar, $errorMark); } if ($wppb_defaultOptions['yahoo'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['yahooRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; if (isset($_POST['yim']) && trim($_POST['yim']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator.', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } $editProfileFilterArray2['contentInfo5'] = ' <p class="form-yim' . $errorVar . '"> <label for="yim">' . __('Yahoo IM', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="yim" type="text" id="yim" value="' . get_the_author_meta('yim', $current_user->id) . '" /> </p><!-- .form-yim -->'; $editProfileFilterArray2['contentInfo5'] = apply_filters('wppb_edit_profile_content_info5', $editProfileFilterArray2['contentInfo5'], $current_user->id, $errorVar, $errorMark); } if ($wppb_defaultOptions['jabber'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['jabberRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; if (isset($_POST['jabber']) && trim($_POST['jabber']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator.', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } $editProfileFilterArray2['contentInfo6'] = ' <p class="form-jabber' . $errorVar . '"> <label for="jabber">' . __('Jabber / Google Talk', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="jabber" type="text" id="jabber" value="' . get_the_author_meta('jabber', $current_user->id) . '" /> </p><!-- .form-jabber -->'; $editProfileFilterArray2['contentInfo6'] = apply_filters('wppb_edit_profile_content_info6', $editProfileFilterArray2['contentInfo6'], $current_user->id, $errorVar, $errorMark); } $editProfileFilterArray2['aboutYourself1'] = '<p class="aboutYourselfHeader"><strong>' . __('About Yourself', 'profilebuilder') . '</strong></p>'; $editProfileFilterArray2['aboutYourself1'] = apply_filters('wppb_edit_profile_content_about_yourself1', $editProfileFilterArray2['aboutYourself1']); if ($wppb_defaultOptions['bio'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['bioRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; if (isset($_POST['description']) && trim($_POST['description']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator.', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } $editProfileFilterArray2['aboutYourself2'] = ' <p class="form-description' . $errorVar . '"> <label for="description">' . __('Biographical Info', 'profilebuilder') . $errorMark . '</label> <textarea class="text-input" name="description" id="description" rows="5" cols="30">' . get_the_author_meta('description', $current_user->id) . '</textarea> </p><!-- .form-description -->'; $editProfileFilterArray2['aboutYourself2'] = apply_filters('wppb_edit_profile_content_about_yourself2', $editProfileFilterArray2['aboutYourself2'], $current_user->id, $errorVar, $errorMark); } if ($wppb_defaultOptions['password'] == 'show') { $editProfileFilterArray2['aboutYourself3'] = ' <p class="form-password"> <label for="pass1">' . __('New Password', 'profilebuilder') . '</label> <input class="text-input" name="pass1" type="password" id="pass1" /> </p><!-- .form-password --> <p class="form-password' . $errorVar . '"> <label for="pass2">' . __('Repeat Password', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="pass2" type="password" id="pass2" /> </p><!-- .form-password -->'; $editProfileFilterArray2['aboutYourself3'] = apply_filters('wppb_edit_profile_content_about_yourself3', $editProfileFilterArray2['aboutYourself3'], $errorVar, $errorMark); } $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { require_once $wppb_premium . 'extra.fields.php'; $page = 'edit_profile'; $returnedValue = wppb_extra_fields($current_user->id, $extraFieldsErrorHolder, $editProfileFilterArray2, $page, $error, $_POST); //copy over extra fields to the rest of the fieldso on the edit profile foreach ($returnedValue as $key => $value) { $editProfileFilterArray2[$key] = apply_filters('wppb_edit_profile_content_' . $key, $value, $returnedValue, $key); } } /* additional filter, just in case it is needed */ $editProfileFilterArray2['extraEditProfileFilter'] = ''; $editProfileFilterArray2['extraEditProfileFilter'] = apply_filters('extraEditProfileFilter', $editProfileFilterArray2['extraEditProfileFilter']); /* END additional filter, just in case it is needed */ $editProfileFilterArray2 = apply_filters('wppb_edit_profile', $editProfileFilterArray2); foreach ($editProfileFilterArray2 as $key => $value) { echo $value; } ?> <p class="form-submit"> <input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?php _e('Update', 'profilebuilder'); ?> " /> <?php // wp_nonce_field( 'update-user' ) ?> <input name="action" type="hidden" id="action" value="update-user" /> </p><!-- .form-submit --> <?php wp_nonce_field('verify_edit_user', 'edit_nonce_field'); ?> </form><!-- #edituser --> <?php //use this action hook to add extra content after the edit profile form. do_action('wppb_after_edit_profile_fields'); } ?> </div> <!--------------------------------------------------------------------------------------> <script src="/wp-content/plugins/profile-builder-pro/assets/js/ksk_phone.js" type="text/javascript"></script> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function wppb_country_select_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Select (Country)') { $item_title = apply_filters('wppb_' . $form_location . '_country_select_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $country_array = wppb_country_select_options($form_location); $old_country_array = array("Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia, Plurinational State of", "Bonaire, Sint Eustatius and Saba", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cabo Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote dIvoire", "Croatia", "Cuba", "Curacao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Republic of", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic Peoples Republic of", "Korea, Republic of", "Kuwait", "Kyrgyzstan", "Lao Peoples Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia, the former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestine, State of", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Barthelemy", "Saint Helena, Ascension and Tristan da Cunha", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten (Dutch part)", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela, Bolivarian Republic of", "Viet Nam", "Virgin Islands, British", "Virgin Islands, U.S.", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe"); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'register') { // change current user country meta_value with country ISO code $user_country_option = wppb_user_meta_exists($user_id, $field['meta-name']); if ($user_country_option != null) { if (in_array($user_country_option->meta_value, $old_country_array)) { $country_iso = array_search($user_country_option->meta_value, $country_array); update_user_meta($user_id, $field['meta-name'], $country_iso); } } $input_value = $user_country_option != null ? $country_array[stripslashes(get_user_meta($user_id, $field['meta-name'], true))] : $country_array[$field['default-option-country']]; } else { $input_value = !empty($field['default-option-country']) ? $country_array[trim($field['default-option-country'])] : ''; } $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? $country_array[trim($request_data[wppb_handle_meta_name($field['meta-name'])])] : $input_value; if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label> <select name="' . $field['meta-name'] . '" id="' . $field['meta-name'] . '" class="custom_field_country_select ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>'; foreach ($country_array as $iso => $country) { $output .= '<option value="' . $iso . '"'; if ($input_value === $country) { $output .= ' selected'; } $output .= '>' . $country . '</option>'; } $output .= ' </select>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td> <select name="' . $field['meta-name'] . '" class="custom_field_country_select" id="' . $field['meta-name'] . '" ' . $extra_attr . '>'; foreach ($country_array as $iso => $country) { $output .= '<option value="' . $iso . '"'; if ($input_value === $country) { $output .= ' selected'; } $output .= '>' . $country . '</option>'; } $output .= '</select> <span class="description">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_country_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_display_recaptcha_default_wp_register() { $field = wppb_get_recaptcha_field(); if (!empty($field)) { $publickey = trim($field['public-key']); $item_title = apply_filters('wppb_register_recaptcha_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); wppb_recaptcha_set_default_values(); if (isset($field['captcha-wp-forms']) && strpos($field['captcha-wp-forms'], 'default_wp_register') !== false) { // check where reCAPTCHA should display and add reCAPTCHA html $recaptcha_output = '<label for="recaptcha_response_field" style="padding-left:15px; padding-bottom:7px;">' . $item_title . '</label>' . wppb_recaptcha_get_html($publickey); if (!empty($item_description)) { $recaptcha_output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } echo '<div class="wppb-form-field wppb-recaptcha" style="margin-left:-14px; margin-bottom: 15px;">' . $recaptcha_output . '</div>'; } } }
function wppb_timepicker_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Timepicker') { $item_title = apply_filters('wppb_' . $form_location . '_timepicker_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'register') { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? stripslashes(get_user_meta($user_id, $field['meta-name'], true)) : ''; } else { $input_value = ''; } $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) && !empty($request_data[wppb_handle_meta_name($field['meta-name'])]['hours']) && !empty($request_data[wppb_handle_meta_name($field['meta-name'])]['minutes']) ? $request_data[wppb_handle_meta_name($field['meta-name'])] : $input_value; // Get the hour and minutes saved for the field $value_hours = ''; $value_minutes = ''; if (is_array($input_value)) { $value_hours = $input_value['hours']; $value_minutes = $input_value['minutes']; } elseif (!empty($input_value)) { $time = explode(':', $input_value); $value_hours = $time[0]; $value_minutes = $time[1]; } // Set hours for time $hours = array(); for ($i = 0; $i <= 23; $i++) { array_push($hours, strlen($i) == 1 ? '0' . $i : $i); } // Set minutes $minutes = array(); for ($i = 0; $i <= 59; $i++) { array_push($minutes, strlen($i) == 1 ? '0' . $i : $i); } if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } // Label $output = ' <label for="' . $field['meta-name'] . '-hour">' . $item_title . $error_mark . '</label>'; // Add hour select $output .= '<select name="' . $field['meta-name'] . '[hours]" id="' . $field['meta-name'] . '-hour" class="custom_field_timepicker_hours ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>'; foreach ($hours as $hour) { $output .= '<option value="' . $hour . '"'; if ($value_hours == $hour) { $output .= ' selected'; } if ($field['time-format'] == '12') { if ($hour > 12) { $hour -= 12; $hour = (strlen($hour) == 1 ? '0' . $hour : $hour) . ' pm'; } elseif ($hour == 12) { $hour .= ' pm'; } elseif ($hour == '00') { $hour = '12 am'; } else { $hour .= ' am'; } } $output .= '>' . $hour . '</option>'; } $output .= '</select>'; // Add divider $output .= '<span class="wppb-timepicker-separator">:</span>'; // Add minutes select $output .= '<select name="' . $field['meta-name'] . '[minutes]" id="' . $field['meta-name'] . '-minutes" class="custom_field_timepicker_minutes ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>'; foreach ($minutes as $minute) { $output .= '<option value="' . $minute . '"'; if ($value_minutes == $minute) { $output .= ' selected'; } $output .= '>' . $minute . '</option>'; } $output .= '</select>'; // Add description if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td>'; // Add hours select $output .= '<select name="' . $field['meta-name'] . '[hours]" class="custom_field_timepicker_hours" id="' . $field['meta-name'] . '-minutes" ' . $extra_attr . '>'; foreach ($hours as $hour) { $output .= '<option value="' . $hour . '"'; if ($value_hours == $hour) { $output .= ' selected'; } if ($field['time-format'] == '12') { if ($hour > 12) { $hour -= 12; $hour = (strlen($hour) == 1 ? '0' . $hour : $hour) . ' pm'; } elseif ($hour == 12) { $hour .= ' pm'; } elseif ($hour == '00') { $hour = '12 am'; } else { $hour .= ' am'; } } $output .= '>' . $hour . '</option>'; } $output .= '</select>'; // Add divider $output .= '<span class="wppb-timepicker-separator">:</span>'; // Add minutes select $output .= '<select name="' . $field['meta-name'] . '[minutes]" class="custom_field_timepicker_minutes" id="' . $field['meta-name'] . '-minutes" ' . $extra_attr . '>'; foreach ($minutes as $minute) { $output .= '<option value="' . $minute . '"'; if ($value_minutes == $minute) { $output .= ' selected'; } $output .= '>' . $minute . '</option>'; } $output .= '</select>'; $output .= '<span class="description">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_currency_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_avatar_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Avatar') { /* media upload add here, this should be added just once even if called multiple times */ wp_enqueue_media(); /* propper way to dequeue. add to functions file in theme or custom plugin function wppb_dequeue_script() { wp_script_is( 'wppb-upload-script', 'enqueued' ); //true wp_dequeue_script( 'wppb-upload-script' ); } add_action( 'get_footer', 'wppb_dequeue_script' ); */ wp_enqueue_script('wppb-upload-script', WPPB_PLUGIN_URL . 'front-end/extra-fields/upload/upload.js', array('jquery'), PROFILE_BUILDER_VERSION, true); wp_enqueue_style('profile-builder-upload-css', WPPB_PLUGIN_URL . 'front-end/extra-fields/upload/upload.css', false, PROFILE_BUILDER_VERSION); $item_title = apply_filters('wppb_' . $form_location . '_avatar_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); if ($form_location != 'register') { if (empty($request_data[wppb_handle_meta_name($field['meta-name'])])) { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : ''; } else { $input_value = $request_data[wppb_handle_meta_name($field['meta-name'])]; } if (!empty($input_value) && !is_numeric($input_value)) { /* we have a file url and we need to change it into an attachment */ // Check the type of file. We'll use this as the 'post_mime_type'. $wp_upload_dir = wp_upload_dir(); $file_path = str_replace($wp_upload_dir['baseurl'], $wp_upload_dir["basedir"], $input_value); //on windows os we might have \ instead of / so change them $file_path = str_replace("\\", "/", $file_path); $file_type = wp_check_filetype(basename($input_value), null); $attachment = array('guid' => $input_value, 'post_mime_type' => $file_type['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($input_value)), 'post_content' => '', 'post_status' => 'inherit'); // Insert the attachment. $input_value = wp_insert_attachment($attachment, $input_value, 0); if (!empty($input_value)) { // Make sure that this file is included, as wp_generate_attachment_metadata() depends on it. require_once ABSPATH . 'wp-admin/includes/image.php'; // Generate the metadata for the attachment, and update the database record. $attach_data = wp_generate_attachment_metadata($input_value, $file_path); wp_update_attachment_metadata($input_value, $attach_data); /* save the new attachment instead of the url */ update_user_meta($user_id, $field['meta-name'], $input_value); } } } else { $input_value = !empty($_POST[$field['meta-name']]) ? $_POST[$field['meta-name']] : ''; } if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = '<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>'; $output .= wppb_make_upload_button($field, $input_value); if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td>'; $output .= wppb_make_upload_button($field, $input_value); $output .= '<br/><span class="wppb-description-delimiter">' . $item_description; $output .= ' </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_avatar_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_country_select_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Select (Country)') { $item_title = apply_filters('wppb_' . $form_location . '_country_select_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $country_array = wppb_country_select_options($form_location); $old_country_array = array(__('Afghanistan', 'profile-builder'), __('Aland Islands', 'profile-builder'), __('Albania', 'profile-builder'), __('Algeria', 'profile-builder'), __('American Samoa', 'profile-builder'), __('Andorra', 'profile-builder'), __('Angola', 'profile-builder'), __('Anguilla', 'profile-builder'), __('Antarctica', 'profile-builder'), __('Antigua and Barbuda', 'profile-builder'), __('Argentina', 'profile-builder'), __('Armenia', 'profile-builder'), __('Aruba', 'profile-builder'), __('Australia', 'profile-builder'), __('Austria', 'profile-builder'), __('Azerbaijan', 'profile-builder'), __('Bahamas', 'profile-builder'), __('Bahrain', 'profile-builder'), __('Bangladesh', 'profile-builder'), __('Barbados', 'profile-builder'), __('Belarus', 'profile-builder'), __('Belgium', 'profile-builder'), __('Belize', 'profile-builder'), __('Benin', 'profile-builder'), __('Bermuda', 'profile-builder'), __('Bhutan', 'profile-builder'), __('Bolivia, __( Plurinational State of', 'profile-builder'), __('Bonaire, __( Sint Eustatius and Saba', 'profile-builder'), __('Bosnia and Herzegovina', 'profile-builder'), __('Botswana', 'profile-builder'), __('Bouvet Island', 'profile-builder'), __('Brazil', 'profile-builder'), __('British Indian Ocean Territory', 'profile-builder'), __('Brunei Darussalam', 'profile-builder'), __('Bulgaria', 'profile-builder'), __('Burkina Faso', 'profile-builder'), __('Burundi', 'profile-builder'), __('Cambodia', 'profile-builder'), __('Cameroon', 'profile-builder'), __('Canada', 'profile-builder'), __('Cabo Verde', 'profile-builder'), __('Cayman Islands', 'profile-builder'), __('Central African Republic', 'profile-builder'), __('Chad', 'profile-builder'), __('Chile', 'profile-builder'), __('China', 'profile-builder'), __('Christmas Island', 'profile-builder'), __('Cocos (Keeling) Islands', 'profile-builder'), __('Colombia', 'profile-builder'), __('Comoros', 'profile-builder'), __('Congo', 'profile-builder'), __('Congo, __( the Democratic Republic of the', 'profile-builder'), __('Cook Islands', 'profile-builder'), __('Costa Rica', 'profile-builder'), __('Cote dIvoire', 'profile-builder'), __('Croatia', 'profile-builder'), __('Cuba', 'profile-builder'), __('Curacao', 'profile-builder'), __('Cyprus', 'profile-builder'), __('Czech Republic', 'profile-builder'), __('Denmark', 'profile-builder'), __('Djibouti', 'profile-builder'), __('Dominica', 'profile-builder'), __('Dominican Republic', 'profile-builder'), __('Ecuador', 'profile-builder'), __('Egypt', 'profile-builder'), __('El Salvador', 'profile-builder'), __('Equatorial Guinea', 'profile-builder'), __('Eritrea', 'profile-builder'), __('Estonia', 'profile-builder'), __('Ethiopia', 'profile-builder'), __('Falkland Islands (Malvinas)', 'profile-builder'), __('Faroe Islands', 'profile-builder'), __('Fiji', 'profile-builder'), __('Finland', 'profile-builder'), __('France', 'profile-builder'), __('French Guiana', 'profile-builder'), __('French Polynesia', 'profile-builder'), __('French Southern Territories', 'profile-builder'), __('Gabon', 'profile-builder'), __('Gambia', 'profile-builder'), __('Georgia', 'profile-builder'), __('Germany', 'profile-builder'), __('Ghana', 'profile-builder'), __('Gibraltar', 'profile-builder'), __('Greece', 'profile-builder'), __('Greenland', 'profile-builder'), __('Grenada', 'profile-builder'), __('Guadeloupe', 'profile-builder'), __('Guam', 'profile-builder'), __('Guatemala', 'profile-builder'), __('Guernsey', 'profile-builder'), __('Guinea', 'profile-builder'), __('Guinea-Bissau', 'profile-builder'), __('Guyana', 'profile-builder'), __('Haiti', 'profile-builder'), __('Heard Island and McDonald Islands', 'profile-builder'), __('Holy See (Vatican City State)', 'profile-builder'), __('Honduras', 'profile-builder'), __('Hong Kong', 'profile-builder'), __('Hungary', 'profile-builder'), __('Iceland', 'profile-builder'), __('India', 'profile-builder'), __('Indonesia', 'profile-builder'), __('Iran, __( Islamic Republic of', 'profile-builder'), __('Iraq', 'profile-builder'), __('Ireland', 'profile-builder'), __('Isle of Man', 'profile-builder'), __('Israel', 'profile-builder'), __('Italy', 'profile-builder'), __('Jamaica', 'profile-builder'), __('Japan', 'profile-builder'), __('Jersey', 'profile-builder'), __('Jordan', 'profile-builder'), __('Kazakhstan', 'profile-builder'), __('Kenya', 'profile-builder'), __('Kiribati', 'profile-builder'), __('Korea, __( Democratic Peoples Republic of', 'profile-builder'), __('Korea, __( Republic of', 'profile-builder'), __('Kuwait', 'profile-builder'), __('Kyrgyzstan', 'profile-builder'), __('Lao Peoples Democratic Republic', 'profile-builder'), __('Latvia', 'profile-builder'), __('Lebanon', 'profile-builder'), __('Lesotho', 'profile-builder'), __('Liberia', 'profile-builder'), __('Libya', 'profile-builder'), __('Liechtenstein', 'profile-builder'), __('Lithuania', 'profile-builder'), __('Luxembourg', 'profile-builder'), __('Macao', 'profile-builder'), __('Macedonia, __( the former Yugoslav Republic of', 'profile-builder'), __('Madagascar', 'profile-builder'), __('Malawi', 'profile-builder'), __('Malaysia', 'profile-builder'), __('Maldives', 'profile-builder'), __('Mali', 'profile-builder'), __('Malta', 'profile-builder'), __('Marshall Islands', 'profile-builder'), __('Martinique', 'profile-builder'), __('Mauritania', 'profile-builder'), __('Mauritius', 'profile-builder'), __('Mayotte', 'profile-builder'), __('Mexico', 'profile-builder'), __('Micronesia, __( Federated States of', 'profile-builder'), __('Moldova, __( Republic of', 'profile-builder'), __('Monaco', 'profile-builder'), __('Mongolia', 'profile-builder'), __('Montenegro', 'profile-builder'), __('Montserrat', 'profile-builder'), __('Morocco', 'profile-builder'), __('Mozambique', 'profile-builder'), __('Myanmar', 'profile-builder'), __('Namibia', 'profile-builder'), __('Nauru', 'profile-builder'), __('Nepal', 'profile-builder'), __('Netherlands', 'profile-builder'), __('New Caledonia', 'profile-builder'), __('New Zealand', 'profile-builder'), __('Nicaragua', 'profile-builder'), __('Niger', 'profile-builder'), __('Nigeria', 'profile-builder'), __('Niue', 'profile-builder'), __('Norfolk Island', 'profile-builder'), __('Northern Mariana Islands', 'profile-builder'), __('Norway', 'profile-builder'), __('Oman', 'profile-builder'), __('Pakistan', 'profile-builder'), __('Palau', 'profile-builder'), __('Palestine, __( State of', 'profile-builder'), __('Panama', 'profile-builder'), __('Papua New Guinea', 'profile-builder'), __('Paraguay', 'profile-builder'), __('Peru', 'profile-builder'), __('Philippines', 'profile-builder'), __('Pitcairn', 'profile-builder'), __('Poland', 'profile-builder'), __('Portugal', 'profile-builder'), __('Puerto Rico', 'profile-builder'), __('Qatar', 'profile-builder'), __('Reunion', 'profile-builder'), __('Romania', 'profile-builder'), __('Russian Federation', 'profile-builder'), __('Rwanda', 'profile-builder'), __('Saint Barthelemy', 'profile-builder'), __('Saint Helena, __( Ascension and Tristan da Cunha', 'profile-builder'), __('Saint Kitts and Nevis', 'profile-builder'), __('Saint Lucia', 'profile-builder'), __('Saint Martin (French part)', 'profile-builder'), __('Saint Pierre and Miquelon', 'profile-builder'), __('Saint Vincent and the Grenadines', 'profile-builder'), __('Samoa', 'profile-builder'), __('San Marino', 'profile-builder'), __('Sao Tome and Principe', 'profile-builder'), __('Saudi Arabia', 'profile-builder'), __('Senegal', 'profile-builder'), __('Serbia', 'profile-builder'), __('Seychelles', 'profile-builder'), __('Sierra Leone', 'profile-builder'), __('Singapore', 'profile-builder'), __('Sint Maarten (Dutch part)', 'profile-builder'), __('Slovakia', 'profile-builder'), __('Slovenia', 'profile-builder'), __('Solomon Islands', 'profile-builder'), __('Somalia', 'profile-builder'), __('South Africa', 'profile-builder'), __('South Georgia and the South Sandwich Islands', 'profile-builder'), __('South Sudan', 'profile-builder'), __('Spain', 'profile-builder'), __('Sri Lanka', 'profile-builder'), __('Sudan', 'profile-builder'), __('Suriname', 'profile-builder'), __('Svalbard and Jan Mayen', 'profile-builder'), __('Swaziland', 'profile-builder'), __('Sweden', 'profile-builder'), __('Switzerland', 'profile-builder'), __('Syrian Arab Republic', 'profile-builder'), __('Taiwan, __( Province of China', 'profile-builder'), __('Tajikistan', 'profile-builder'), __('Tanzania, __( United Republic of', 'profile-builder'), __('Thailand', 'profile-builder'), __('Timor-Leste', 'profile-builder'), __('Togo', 'profile-builder'), __('Tokelau', 'profile-builder'), __('Tonga', 'profile-builder'), __('Trinidad and Tobago', 'profile-builder'), __('Tunisia', 'profile-builder'), __('Turkey', 'profile-builder'), __('Turkmenistan', 'profile-builder'), __('Turks and Caicos Islands', 'profile-builder'), __('Tuvalu', 'profile-builder'), __('Uganda', 'profile-builder'), __('Ukraine', 'profile-builder'), __('United Arab Emirates', 'profile-builder'), __('United Kingdom', 'profile-builder'), __('United States', 'profile-builder'), __('United States Minor Outlying Islands', 'profile-builder'), __('Uruguay', 'profile-builder'), __('Uzbekistan', 'profile-builder'), __('Vanuatu', 'profile-builder'), __('Venezuela, __( Bolivarian Republic of', 'profile-builder'), __('Viet Nam', 'profile-builder'), __('Virgin Islands, __( British', 'profile-builder'), __('Virgin Islands, __( U.S.', 'profile-builder'), __('Wallis and Futuna', 'profile-builder'), __('Western Sahara', 'profile-builder'), __('Yemen', 'profile-builder'), __('Zambia', 'profile-builder'), __('Zimbabwe', 'profile-builder')); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'register') { // change current user country meta_value with country ISO code $user_country_option = wppb_user_meta_exists($user_id, $field['meta-name']); if ($user_country_option != null) { if (in_array($user_country_option->meta_value, $old_country_array)) { $country_iso = array_search($user_country_option->meta_value, $country_array); update_user_meta($user_id, $field['meta-name'], $country_iso); } } $input_value = $user_country_option != null ? $country_array[stripslashes(get_user_meta($user_id, $field['meta-name'], true))] : $country_array[$field['default-option-country']]; } else { $input_value = !empty($field['default-option-country']) ? $country_array[trim($field['default-option-country'])] : ''; } $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? $country_array[trim($request_data[wppb_handle_meta_name($field['meta-name'])])] : $input_value; if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label> <select name="' . $field['meta-name'] . '" id="' . $field['meta-name'] . '" class="custom_field_country_select ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>'; $extra_select_option = apply_filters('wppb_extra_select_option', '', $field, $item_title); if (!empty($extra_select_option)) { $output .= $extra_select_option; $country_array = array_filter($country_array); } foreach ($country_array as $iso => $country) { $output .= '<option value="' . $iso . '"'; if ($input_value === $country) { $output .= ' selected'; } $output .= '>' . $country . '</option>'; } $output .= ' </select>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $output = ' <table class="form-table"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td> <select name="' . $field['meta-name'] . '" class="custom_field_country_select" id="' . $field['meta-name'] . '" ' . $extra_attr . '>'; foreach ($country_array as $iso => $country) { $output .= '<option value="' . $iso . '"'; if ($input_value === $country) { $output .= ' selected'; } $output .= '>' . $country . '</option>'; } $output .= '</select> <span class="description">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_country_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_select2_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Select2') { wp_enqueue_script('wppb_select2', WPPBSL2_PLUGIN_URL . 'assets/js/select2_init.js', array('jquery')); wp_enqueue_script('wppb_sl2_lib_js', WPPBSL2_PLUGIN_URL . 'assets/select2-lib/dist/js/select2.min.js', array('jquery')); wp_enqueue_style('wppb_sl2_lib_css', WPPBSL2_PLUGIN_URL . 'assets/select2-lib/dist/css/select2.min.css'); wp_enqueue_style('wppb_sl2_css', WPPBSL2_PLUGIN_URL . 'assets/css/style-front-end.css'); $item_title = apply_filters('wppb_' . $form_location . '_select2_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $item_option_labels = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_option_labels_translation', $field['labels']); $select2_labels = explode(',', $item_option_labels); $select2_values = explode(',', $field['options']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'register') { $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? stripslashes(get_user_meta($user_id, $field['meta-name'], true)) : $field['default-option']; } else { $input_value = !empty($field['default-option']) ? trim($field['default-option']) : ''; } $input_value = isset($request_data[wppb_sl2_handle_meta_name($field['meta-name'])]) ? stripslashes(trim($request_data[wppb_sl2_handle_meta_name($field['meta-name'])])) : $input_value; if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label> <select name="' . $field['meta-name'] . '" id="' . $field['meta-name'] . '" class="custom_field_select2" ' . $extra_attr . '>'; foreach ($select2_values as $key => $value) { $output .= '<option value="' . esc_attr(trim($value)) . '" class="custom_field_select2_option ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" '; if ($input_value === trim($value)) { $output .= ' selected'; } $output .= '>' . (!isset($select2_labels[$key]) || !$select2_labels[$key] ? trim($select2_values[$key]) : trim($select2_labels[$key])) . '</option>'; } $output .= ' </select>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } else { $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title; $output = ' <table class="form-table wppb-select2"> <tr> <th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th> <td> <select name="' . $field['meta-name'] . '" class="custom_field_select2" id="' . $field['meta-name'] . '" ' . $extra_attr . '>'; foreach ($select2_values as $key => $value) { $output .= '<option value="' . esc_attr(trim($value)) . '" class="custom_field_select2_option" '; if ($input_value === trim($value)) { $output .= ' selected'; } $output .= '>' . (!isset($select2_labels[$key]) || !$select2_labels[$key] ? trim($select2_values[$key]) : trim($select2_labels[$key])) . '</option>'; } $output .= '</select> <span class="description">' . $item_description . '</span> </td> </tr> </table>'; } return apply_filters('wppb_' . $form_location . '_select2_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function wppb_user_role_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Select (User Role)') { $user_role = ''; $user_can_manage_options = false; // Get user data, set user's role and check to see if user can manage options if ($user_id != 0) { $user_data = get_userdata($user_id); $user_role = $user_data->roles[0]; if (isset($user_data->allcaps['manage_options']) && $user_data->allcaps['manage_options'] == 1) { $user_can_manage_options = true; } } $input_value = isset($request_data['custom_field_user_role']) ? $request_data['custom_field_user_role'] : $user_role; $item_title = apply_filters('wppb_' . $form_location . '_user_role_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); //get user roles if (!empty($field['user-roles'])) { global $wp_roles; $available_user_roles = explode(', ', $field['user-roles']); foreach ($available_user_roles as $key => $role_slug) { if (isset($wp_roles->roles[$role_slug]['name'])) { $available_user_roles[$key] = array('slug' => $role_slug, 'name' => $wp_roles->roles[$role_slug]['name']); } else { unset($available_user_roles[$key]); } } } $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location == 'register' || $form_location == 'edit_profile' && current_user_can('manage_options') && $user_can_manage_options == false) { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="custom_field_user_role">' . $item_title . $error_mark . '</label> <select name="custom_field_user_role" id="' . $field['meta-name'] . '" class="custom_field_user_role ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>'; if (!empty($available_user_roles)) { foreach ($available_user_roles as $user_role) { $output .= '<option value="' . $user_role['slug'] . '"'; $output .= selected($input_value, $user_role['slug'], false); $output .= '>' . $user_role['name'] . '</option>'; } } $output .= '</select>'; if ($form_location == 'edit_profile') { $output .= '<span class="wppb-description-delimiter">' . __('Only administrators can see this field on edit profile forms.', 'profile-builder') . '</span>'; } if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } elseif ($form_location == 'edit_profile' && current_user_can('manage_options') && $user_can_manage_options == true) { $output = ' <label for="custom_field_user_role">' . $item_title . '</label> <p>' . __('As an administrator you cannot change your role.', 'profile-builder') . '</p>'; $output .= '</select>'; $output .= '<span class="wppb-description-delimiter">' . __('Only administrators can see this field on edit profile forms.', 'profile-builder') . '</span>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } return apply_filters('wppb_' . $form_location . '_user_role_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function save_profile_extra_fields_in_admin($user_id) { if (!current_user_can('edit_user', $user_id)) { return false; } /* fetch a new custom-fields (only the types) array from the database */ $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "input": update_user_meta($user_id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "hiddenInput": update_user_meta($user_id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "checkbox": $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']); $checkboxOption = ''; $checkboxValue = explode(',', $value['item_options']); foreach ($checkboxValue as $thisValue) { $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post if (isset($_POST[$thisValue . $value['id']])) { $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue . $value['id']]); $checkboxOption = $checkboxOption . $localValue . ','; } } update_user_meta($user_id, $value['item_metaName'], esc_attr($checkboxOption)); break; case "radio": update_user_meta($user_id, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "select": update_user_meta($user_id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "countrySelect": update_user_meta($user_id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "timeZone": update_user_meta($user_id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "datepicker": update_user_meta($user_id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "textarea": update_user_meta($user_id, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "upload": $uploadedfile = $value['item_type'] . $value['id']; $target_path = "../wp-content/uploads/profile_builder/attachments/"; $target_path = $target_path . 'userID_' . $user_id . '_attachment_' . basename($_FILES[$uploadedfile]['name']); if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) { $upFile = get_bloginfo('home') . '/' . $target_path; $upFile = str_replace('../', '', $upFile); update_user_meta($user_id, $value['item_metaName'], $upFile); } break; case "avatar": $uploadedfile = $value['item_type'] . $value['id']; $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $target_path_original = $wpUploadPath['basedir'] . '/profile_builder/avatars/'; $fileName = $_FILES[$uploadedfile]['name']; //replace all spaces with an underscore $finalFileName = ''; for ($i = 0; $i < strlen($fileName); $i++) { if ($fileName[$i] == "'") { $finalFileName .= '`'; } elseif ($fileName[$i] == ' ') { $finalFileName .= '_'; } else { $finalFileName .= $fileName[$i]; } } $fileName = $finalFileName; $target_path = $target_path_original . 'userID_' . $user_id . '_originalAvatar_' . $fileName; // when trying to upload file, be sure it's one of the accepted image file-types if (($_FILES[$uploadedfile]['type'] == 'image/jpeg' || $_FILES[$uploadedfile]['type'] == 'image/jpg' || $_FILES[$uploadedfile]['type'] == 'image/png' || $_FILES[$uploadedfile]['type'] == 'image/bmp' || $_FILES[$uploadedfile]['type'] == 'image/pjpeg' || $_FILES[$uploadedfile]['type'] == 'image/x-png') && ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0)) { $wp_filetype = wp_check_filetype(basename($_FILES[$uploadedfile]['name']), null); $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $fileName, 'post_content' => '', 'post_status' => 'inherit'); $attach_id = wp_insert_attachment($attachment, $target_path); $upFile = image_downsize($attach_id, 'thumbnail'); $upFile = $upFile[0]; //if file upload succeded if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) { update_user_meta($user_id, $value['item_metaName'], $upFile); update_user_meta($user_id, 'resized_avatar_' . $value['id'], ''); } } break; } } }
function wppb_front_end_register($atts) { ob_start(); global $current_user; global $wp_roles; global $wpdb; global $error; global $wppb_shortcode_on_front; //get required and shown fields $wppb_defaultOptions = get_option('wppb_default_settings'); //get "login with" setting $wppb_generalSettings = get_option('wppb_general_settings'); $wppb_shortcode_on_front = true; $agreed = true; $new_user = '******'; $multisite_message = false; $registerFilterArray = array(); $registerFilterArray2 = array(); $uploadExt = array(); $extraFieldsErrorHolder = array(); //we will use this array to store the ID's of the extra-fields left uncompleted get_currentuserinfo(); /* variables used to verify if all required fields were submitted*/ $firstnameComplete = 'yes'; $lastnameComplete = 'yes'; $nicknameComplete = 'yes'; $websiteComplete = 'yes'; $aimComplete = 'yes'; $yahooComplete = 'yes'; $jabberComplete = 'yes'; $bioComplete = 'yes'; /* END variables used to verify if all required fields were submitted*/ /* Check if users can register. */ $registration = get_option('users_can_register'); $registration = apply_filters('wppb_register_setting_override', $registration); //fallback if the file was largen then post_max_size, case in which no errors can be saved in $_FILES[fileName]['error'] if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') { $registerFilterArray['noPostError'] = '<p class="error">' . sprintf(__('The information size you were trying to submit was larger than %1$sb!<br/>This is usually caused by a large file(s) trying to be uploaded.<br/>Since it was also larger than %2$sb no additional information is available.<br/>The user was NOT created!', 'profilebuilder'), WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA, WPPB_SERVER_MAX_POST_SIZE_MEGA) . '</p>'; echo $registerFilterArray['noPostError'] = apply_filters('wppb_register_no_post_error_message', $registerFilterArray['noPostError'], WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA, WPPB_SERVER_MAX_POST_SIZE_MEGA); } /* If user registered, input info. */ if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'adduser' && wp_verify_nonce($_POST['register_nonce_field'], 'verify_true_registration') && $_POST['formName'] == 'register') { //global $wp_roles; //get value sent in the shortcode as parameter, use default if not set $default_role = get_option('default_role'); extract(shortcode_atts(array('role' => $default_role), $atts)); //check if the specified role exists in the database, else fall back to the "safe-zone" $aprovedRole = $role == $default_role || get_role($role) ? $role : $default_role; /* preset the values in case some are not submitted */ $user_pass = ''; if (isset($_POST['passw1'])) { $user_pass = esc_attr($_POST['passw1']); } $email = ''; if (isset($_POST['email'])) { $email = trim($_POST['email']); } if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { $user_name = wppb_generate_random_username($email); } else { $user_name = ''; if (isset($_POST['user_name'])) { $user_name = trim($_POST['user_name']); } } $first_name = ''; if (isset($_POST['first_name'])) { $first_name = trim($_POST['first_name']); } $last_name = ''; if (isset($_POST['last_name'])) { $last_name = trim($_POST['last_name']); } $nickname = ''; if (isset($_POST['nickname'])) { //the field is filled by the user upon registration $nickname = trim($_POST['nickname']); } elseif (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { //in case the nickname field is hidden, and the login with email is active $nickname = $email; } else { //in case the nickname field is hidden, but login is done with username $nickname = $user_name; } $website = ''; if (isset($_POST['website'])) { $website = trim($_POST['website']); } $aim = ''; if (isset($_POST['aim'])) { $aim = trim($_POST['aim']); } $yim = ''; if (isset($_POST['yim'])) { $yim = trim($_POST['yim']); } $jabber = ''; if (isset($_POST['jabber'])) { $jabber = trim($_POST['jabber']); } $description = ''; if (isset($_POST['description'])) { $description = trim($_POST['description']); } /* use filters to modify (if needed) the posted data before creating the user-data */ $user_pass = apply_filters('wppb_register_posted_password', $user_pass); $user_name = apply_filters('wppb_register_posted_username', $user_name); $first_name = apply_filters('wppb_register_posted_first_name', $first_name); $last_name = apply_filters('wppb_register_posted_last_name', $last_name); $nickname = apply_filters('wppb_register_posted_nickname', $nickname); $email = apply_filters('wppb_register_posted_email', $email); $website = apply_filters('wppb_register_posted_website', $website); $aim = apply_filters('wppb_register_posted_aim', $aim); $yim = apply_filters('wppb_register_posted_yahoo', $yim); $jabber = apply_filters('wppb_register_posted_jabber', $jabber); $description = apply_filters('wppb_register_posted_bio', $description); /* END use filters to modify (if needed) the posted data before creating the user-data */ $userdata = array('user_pass' => $user_pass, 'user_login' => esc_attr($user_name), 'first_name' => esc_attr($first_name), 'last_name' => esc_attr($last_name), 'nickname' => esc_attr($nickname), 'user_email' => esc_attr($email), 'user_url' => esc_attr($website), 'aim' => esc_attr($aim), 'yim' => esc_attr($yim), 'jabber' => esc_attr($jabber), 'description' => esc_attr($description), 'role' => $aprovedRole); $userdata = apply_filters('wppb_register_userdata', $userdata); //check if the user agreed to the terms and conditions (if it was set) $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "agreeToTerms": $agreed = false; if (isset($_POST[$value['item_type'] . $value['id']]) && $_POST[$value['item_type'] . $value['id']] == 'agree') { $agreed = true; } break; } // add filters for all the custom fields $_POST[$value['item_type'] . $value['id']] = apply_filters('wppb_register_' . $value['item_type'] . $value['id'] . '_general_filter', $_POST[$value['item_type'] . $value['id']]); } } $registerFilterArray['extraError'] = ''; //this is for creating extra error message and bypassing registration $registerFilterArray['extraError'] = apply_filters('wppb_register_extra_error', $registerFilterArray['extraError']); /* check if all the required fields were completed */ if ($wppb_defaultOptions['firstname'] == 'show') { if ($wppb_defaultOptions['firstnameRequired'] == 'yes' && trim($_POST['first_name']) == '') { $firstnameComplete = 'no'; } } if ($wppb_defaultOptions['lastname'] == 'show') { if ($wppb_defaultOptions['lastnameRequired'] == 'yes' && trim($_POST['last_name']) == '') { $lastnameComplete = 'no'; } } if ($wppb_defaultOptions['nickname'] == 'show') { if ($wppb_defaultOptions['nicknameRequired'] == 'yes' && trim($_POST['nickname']) == '') { $nicknameComplete = 'no'; } } if ($wppb_defaultOptions['website'] == 'show') { if ($wppb_defaultOptions['websiteRequired'] == 'yes' && trim($_POST['website']) == '') { $websiteComplete = 'no'; } } if ($wppb_defaultOptions['aim'] == 'show') { if ($wppb_defaultOptions['aimRequired'] == 'yes' && trim($_POST['aim']) == '') { $aimComplete = 'no'; } } if ($wppb_defaultOptions['yahoo'] == 'show') { if ($wppb_defaultOptions['yahooRequired'] == 'yes' && trim($_POST['yahoo']) == '') { $yahooComplete = 'no'; } } if ($wppb_defaultOptions['jabber'] == 'show') { if ($wppb_defaultOptions['jabberRequired'] == 'yes' && trim($_POST['jabber']) == '') { $jabberComplete = 'no'; } } if ($wppb_defaultOptions['bio'] == 'show') { if ($wppb_defaultOptions['bioRequired'] == 'yes' && trim($_POST['description']) == '') { $bioComplete = 'no'; } } // check the extra fields also $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "input": $_POST[$value['item_type'] . $value['id']] = apply_filters('wppb_register_input_custom_field_' . $value['id'], $_POST[$value['item_type'] . $value['id']]); if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "checkbox": $checkboxOption = ''; $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']); $checkboxValue = explode(',', $value['item_options']); foreach ($checkboxValue as $thisValue) { $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post if (isset($_POST[$thisValue . $value['id']])) { $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue . $value['id']]); $checkboxOption = $checkboxOption . $localValue . ','; } } if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($checkboxOption) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "radio": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "select": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "countrySelect": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "timeZone": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "datepicker": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "textarea": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "upload": $uploadedfile = $value['item_type'] . $value['id']; if (basename($_FILES[$uploadedfile]['name']) == '') { if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { array_push($extraFieldsErrorHolder, $value['id']); } } } elseif (basename($_FILES[$uploadedfile]['name']) != '') { //get allowed file types if ($value['item_options'] != NULL || $value['item_options'] != '') { $allFiles = false; $extensions = explode(',', $value['item_options']); foreach ($extensions as $key2 => $value2) { $extensions[$key2] = trim($value2); } } else { $allFiles = true; } $thisFileExtStart = strrpos($_FILES[$uploadedfile]['name'], '.'); $thisFileExt = substr($_FILES[$uploadedfile]['name'], $thisFileExtStart); if ($allFiles == false && !in_array($thisFileExt, $extensions)) { array_push($uploadExt, basename($_FILES[$uploadedfile]['name'])); $allowedExtensions = ''; (int) ($nrOfExt = count($extensions) - 2); foreach ($extensions as $key2 => $value2) { $allowedExtensions .= $value2; if ($key2 <= $nrOfExt) { $allowedExtensions .= ', '; } } } } break; case "avatar": $uploadedfile = $value['item_type'] . $value['id']; if (basename($_FILES[$uploadedfile]['name']) == '') { if ($_FILES[$uploadedfile]['type'] != 'image/jpeg' || $_FILES[$uploadedfile]['type'] != 'image/jpg' || $_FILES[$uploadedfile]['type'] != 'image/png' || $_FILES[$uploadedfile]['type'] != 'image/bmp' || $_FILES[$uploadedfile]['type'] != 'image/pjpeg' || $_FILES[$uploadedfile]['type'] != 'image/x-png') { if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { array_push($extraFieldsErrorHolder, $value['id']); } } } } break; case "agreeToTerms": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if ($_POST[$value['item_type'] . $value['id']] == NULL) { array_push($extraFieldsErrorHolder, $value['id']); } } } break; } } } /* END check if all the required fields were completed */ if ($registerFilterArray['extraError'] != '') { $error = $registerFilterArray['extraError']; } elseif (!$userdata['user_login']) { if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { } else { $error = apply_filters('wppb_register_userlogin_error1', __('A username is required for registration.', 'profilebuilder')); } } elseif (username_exists($userdata['user_login'])) { if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { } else { $error = apply_filters('wppb_register_userlogin_error2', __('Sorry, that username already exists!', 'profilebuilder')); } } elseif (!is_email($userdata['user_email'], true)) { $error = apply_filters('wppb_register_useremail_error1', __('You must enter a valid email address.', 'profilebuilder')); } elseif (email_exists($userdata['user_email'])) { $error = apply_filters('wppb_register_useremail_error2', __('Sorry, that email address is already used!', 'profilebuilder')); } elseif (empty($_POST['passw1']) || empty($_POST['passw2']) || $_POST['passw1'] != $_POST['passw2']) { if (empty($_POST['passw1']) || empty($_POST['passw2'])) { //verify if the user has completed both password fields $error = apply_filters('wppb_register_userpass_error1', __('You didn\'t complete one of the password-fields!', 'profilebuilder')); } elseif ($_POST['passw1'] != $_POST['passw2']) { //verify if the the password and the retyped password are a match $error = apply_filters('wppb_register_userpass_error2', __('The entered passwords don\'t match!', 'profilebuilder')); } } elseif (count($uploadExt) > 0) { $error = '<p class="semi-saved">' . __('There was an error while trying to upload the following attachment(s)', 'profilebuilder') . ': <span class="error">'; foreach ($uploadExt as $key5 => $name5) { $lastOne++; $error .= $name5; if (count($uploadExt) - $lastOne > 0) { $error .= ';<span style="padding-left:10px"></span>'; } } $error .= '</span><br/>' . __('Only files with the following extension(s) can be uploaded:', 'profilebuilder') . ' <span class="error">' . $allowedExtensions . '</span><br/><span class="error">' . __('The account was NOT created!', 'profilebuilder') . '</span> </p>'; } elseif ($agreed == false) { $error = __('You must agree to the terms and conditions before registering!', 'profilebuilder'); } elseif ($firstnameComplete == 'no' || $lastnameComplete == 'no' || $nicknameComplete == 'no' || $websiteComplete == 'no' || $aimComplete == 'no' || $yahooComplete == 'no' || $jabberComplete == 'no' || $bioComplete == 'no' || !empty($extraFieldsErrorHolder)) { $error = __('The account was NOT created!', 'profilebuilder') . '<br/>' . __('(Several required fields were left uncompleted)', 'profilebuilder'); } else { $registered_name = $_POST['user_name']; //register the user normally if it is not a multi-site installation if (!is_multisite()) { $wppb_generalSettings = get_option('wppb_general_settings'); if ($wppb_generalSettings['emailConfirmation'] == 'yes') { $foundError = false; if (is_multisite()) { $userSignup = $wpdb->get_results("SELECT * FROM {$wpdb->signups} WHERE user_login='******'user_login'] . "' OR user_email='" . $userdata['user_email'] . "'"); } else { $userSignup = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "signups WHERE user_login='******'user_login'] . "' OR user_email='" . $userdata['user_email'] . "'"); } if (trim($userSignup[0]->user_login) == $userdata['user_login']) { $foundError = true; $error = __('This username is already reserved to be used soon.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder'); } elseif (trim($userSignup[0]->user_email) == $userdata['user_email']) { $foundError = true; $error = __('This email address is already reserved to be used soon.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder'); } if ($foundError) { } else { $new_user = '******'; $multisite_message = true; $meta = array('user_pass' => base64_encode($userdata['user_pass']), 'first_name' => $userdata['first_name'], 'last_name' => $userdata['last_name'], 'nickname' => $userdata['nickname'], 'user_url' => $userdata['user_url'], 'aim' => $userdata['aim'], 'yim' => $userdata['yim'], 'jabber' => $userdata['jabber'], 'description' => $userdata['description'], 'role' => $userdata['role']); $meta = wppb_add_custom_field_values($_POST, $meta); wppb_signup_user($userdata['user_login'], $userdata['user_email'], $meta); } } else { $new_user = wp_insert_user($userdata); /* add the extra profile information */ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "input": add_user_meta($new_user, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "hiddenInput": add_user_meta($new_user, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "checkbox": $checkboxOption = ''; $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']); $checkboxValue = explode(',', $value['item_options']); foreach ($checkboxValue as $thisValue) { $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post if (isset($_POST[$thisValue . $value['id']])) { $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue . $value['id']]); $checkboxOption = $checkboxOption . $localValue . ','; } } add_user_meta($new_user, $value['item_metaName'], $checkboxOption); break; case "radio": add_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "select": add_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "countrySelect": update_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "timeZone": update_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "datepicker": update_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "textarea": add_user_meta($new_user, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "upload": $uploadedfile = $value['item_type'] . $value['id']; //first we need to verify if we don't try to upload a 0b or 0 length file if (basename($_FILES[$uploadedfile]['name']) != '') { //second we need to verify if the uploaded file size is less then the set file size in php.ini if ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0) { //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error $fileName = basename($_FILES[$uploadedfile]['name']); $finalFileName = ''; for ($i = 0; $i < strlen($fileName); $i++) { if ($fileName[$i] == "'") { $finalFileName .= '`'; } else { $finalFileName .= $fileName[$i]; } } //create the target path for uploading $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $target_path = $wpUploadPath['basedir'] . "/profile_builder/attachments/"; $target_path = $target_path . 'userID_' . $new_user . '_attachment_' . $finalFileName; if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) { //$upFile = get_bloginfo('home').'/'.$target_path; $upFile = $wpUploadPath['baseurl'] . '/profile_builder/attachments/userID_' . $new_user . '_attachment_' . $finalFileName; add_user_meta($new_user, $value['item_metaName'], $upFile); $pictureUpload = 'yes'; } } } break; case "avatar": $uploadedfile = $value['item_type'] . $value['id']; $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $target_path_original = $wpUploadPath['basedir'] . "/profile_builder/avatars/"; $fileName = $_FILES[$uploadedfile]['name']; $finalFileName = ''; for ($i = 0; $i < strlen($fileName); $i++) { if ($fileName[$i] == "'") { $finalFileName .= '`'; } elseif ($fileName[$i] == ' ') { $finalFileName .= '_'; } else { $finalFileName .= $fileName[$i]; } } $fileName = $finalFileName; $target_path = $target_path_original . 'userID_' . $new_user . '_originalAvatar_' . $fileName; /* when trying to upload file, be sure it's one of the accepted image file-types */ if (($_FILES[$uploadedfile]['type'] == 'image/jpeg' || $_FILES[$uploadedfile]['type'] == 'image/jpg' || $_FILES[$uploadedfile]['type'] == 'image/png' || $_FILES[$uploadedfile]['type'] == 'image/bmp' || $_FILES[$uploadedfile]['type'] == 'image/pjpeg' || $_FILES[$uploadedfile]['type'] == 'image/x-png') && ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0)) { $wp_filetype = wp_check_filetype(basename($_FILES[$uploadedfile]['name']), null); $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $fileName, 'post_content' => '', 'post_status' => 'inherit'); $attach_id = wp_insert_attachment($attachment, $target_path); $upFile = image_downsize($attach_id, 'thumbnail'); $upFile = $upFile[0]; //if file upload succeded if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) { add_user_meta($new_user, $value['item_metaName'], $upFile); wppb_resize_avatar($new_user); $avatarUpload = 'yes'; } else { $avatarUpload = 'no'; } } if ($_FILES[$uploadedfile]['type'] == '') { $avatarUpload = 'yes'; } break; } } } // if admin approval is activated, then block the user untill he gets approved $wppb_generalSettings = get_option('wppb_general_settings', 'not_found'); if ($wppb_generalSettings != 'not_found') { if ($wppb_generalSettings['adminApproval'] == 'yes') { wp_set_object_terms($new_user, array('unapproved'), 'user_status', false); clean_object_term_cache($new_user, 'user_status'); } } // send an email to the admin, and - if selected - to the user also. $bloginfo = get_bloginfo('name'); $sentEmailStatus = wppb_notify_user_registration_email($bloginfo, esc_attr($_POST['user_name']), esc_attr($_POST['email']), $_POST['send_credentials_via_email'], $_POST['passw1'], $wppb_generalSettings['adminApproval']); } } elseif (is_multisite()) { //validate username and email $validationRes = wpmu_validate_user_signup($userdata['user_login'], $userdata['user_email']); $error = apply_filters('wppb_register_wpmu_registration_error', $validationRes['errors']->get_error_message()); if (trim($error) != '') { } else { $new_user = '******'; $multisite_message = true; $meta = array('user_pass' => base64_encode($userdata['user_pass']), 'first_name' => $userdata['first_name'], 'last_name' => $userdata['last_name'], 'nickname' => $userdata['nickname'], 'user_url' => $userdata['user_url'], 'aim' => $userdata['aim'], 'yim' => $userdata['yim'], 'jabber' => $userdata['jabber'], 'description' => $userdata['description'], 'role' => $userdata['role']); $meta = wppb_add_custom_field_values($_POST, $meta); wppb_signup_user($userdata['user_login'], $userdata['user_email'], $meta); } } } } ?> <div class="wppb_holder" id="wppb_register"> <?php if (is_user_logged_in() && !current_user_can('create_users')) { global $user_ID; $login = get_userdata($user_ID); if ($login->display_name == '') { $login->display_name = $login->user_login; } $registerFilterArray['loginLogoutError'] = ' <p class="log-in-out alert">' . __('You are logged in as', 'profilebuilder') . ' <a href="' . get_author_posts_url($login->ID) . '" title="' . $login->display_name . '">' . $login->display_name . '</a>. ' . __('You don\'t need another account.', 'profilebuilder') . ' <a href="' . wp_logout_url(get_permalink()) . '" title="' . __('Log out of this account.', 'profilebuilder') . '">' . __('Logout', 'profilebuilder') . ' »</a></p><!-- .log-in-out .alert -->'; $registerFilterArray['loginLogoutError'] = apply_filters('wppb_register_have_account_alert', $registerFilterArray['loginLogoutError'], $login->ID); echo $registerFilterArray['loginLogoutError']; } elseif ($new_user != 'no') { if (current_user_can('create_users')) { if ($multisite_message) { $registerFilterArray['wpmuRegistrationMessage1'] = '<p class="success">' . sprintf(__('An email has been sent to %1$s with information on how to activate his/her account.', 'profilebuilder'), $userdata['user_email']) . '</p><!-- .success -->'; echo $registerFilterArray['registrationMessage1'] = apply_filters('wppb_wpmu_register_account_created1', $registerFilterArray['wpmuRegistrationMessage1'], $registered_name, $userdata['user_email']); } else { $registerFilterArray['registrationMessage1'] = '<p class="success">' . sprintf(__('A user account has been created for %1$s.', 'profilebuilder'), $registered_name) . '</p><!-- .success -->'; echo $registerFilterArray['registrationMessage1'] = apply_filters('wppb_register_account_created1', $registerFilterArray['registrationMessage1'], $registered_name); } $redirectLink = wppb_curpageurl(); if (file_exists(WPPB_PLUGIN_DIR . '/premium/addons/addon.php')) { //check to see if the redirecting addon is present and activated $wppb_addon_settings = get_option('wppb_addon_settings'); if ($wppb_addon_settings['wppb_customRedirect'] == 'show') { //check to see if the redirect location is not an empty string and is activated $customRedirectSettings = get_option('customRedirectSettings'); if (trim($customRedirectSettings['afterRegisterTarget']) != '' && $customRedirectSettings['afterRegister'] == 'yes') { $redirectLink = trim($customRedirectSettings['afterRegisterTarget']); if (wppb_check_missing_http($redirectLink)) { $redirectLink = 'http://' . $redirectLink; } } } } $registerFilterArray['redirectMessage1'] = '<font id="messageTextColor">' . sprintf(__('You will soon be redirected automatically. If you see this page for more than 3 seconds, please click %1$s.%2$s', 'profilebuilder'), '<a href="' . $redirectLink . '">' . __('here', 'profilebuilder') . '</a>', '<meta http-equiv="Refresh" content="3;url=' . $redirectLink . '" />') . '</font><br/><br/>'; echo $registerFilterArray['redirectMessage1'] = apply_filters('wppb_register_redirect_after_creation1', $registerFilterArray['redirectMessage1'], $redirectLink); } else { if ($multisite_message) { $registerFilterArray['wpmuRegistrationMessage2'] = '<p class="success">' . __('An email has been sent to you with information on how to activate your account.', 'profilebuilder') . '</p><!-- .success -->'; echo $registerFilterArray['wpmuRegistrationMessage2'] = apply_filters('wppb_register_account_created2', $registerFilterArray['wpmuRegistrationMessage2'], $registered_name); } else { $registerFilterArray['registrationMessage2'] = '<p class="success">' . sprintf(__('Thank you for registering %1$s.', 'profilebuilder'), $registered_name) . '</p><!-- .success -->'; echo $registerFilterArray['registrationMessage2'] = apply_filters('wppb_register_account_created2', $registerFilterArray['registrationMessage2'], $registered_name); } $redirectLink = wppb_curpageurl(); if (file_exists(WPPB_PLUGIN_DIR . '/premium/addons/addon.php')) { //check to see if the redirecting addon is present and activated $wppb_addon_settings = get_option('wppb_addon_settings'); if ($wppb_addon_settings['wppb_customRedirect'] == 'show') { //check to see if the redirect location is not an empty string and is activated $customRedirectSettings = get_option('customRedirectSettings'); if (trim($customRedirectSettings['afterRegisterTarget']) != '' && $customRedirectSettings['afterRegister'] == 'yes') { $redirectLink = trim($customRedirectSettings['afterRegisterTarget']); if (wppb_check_missing_http($redirectLink)) { $redirectLink = 'http://' . $redirectLink; } } } } $registerFilterArray['redirectMessage2'] = '<font id="messageTextColor">' . sprintf(__('You will soon be redirected automatically. If you see this page for more than 3 seconds, please click %1$s.%2$s', 'profilebuilder'), '<a href="' . $redirectLink . '">' . __('here', 'profilebuilder') . '</a>', '<meta http-equiv="Refresh" content="3;url=' . $redirectLink . '" />') . '</font><br/><br/>'; echo $registerFilterArray['redirectMessage2'] = apply_filters('wppb_register_redirect_after_creation2', $registerFilterArray['redirectMessage2'], $redirectLink); } if (isset($_POST['send_credentials_via_email'])) { if ($sentEmailStatus == 1) { $registerFilterArray['emailMessage1'] = '<p class="error">' . __('An error occured while trying to send the notification email.', 'profilebuilder') . '</p><!-- .error -->'; $registerFilterArray['emailMessage1'] = apply_filters('wppb_register_send_notification_email_fail', $registerFilterArray['emailMessage1']); echo $registerFilterArray['emailMessage1']; } elseif ($sentEmailStatus == 2) { if ($multisite_message) { $registerFilterArray['wpmuEmailMessage2'] = '<p class="success">' . __('An email containing activation instructions was successfully sent.', 'profilebuilder') . '</p><!-- .success -->'; $registerFilterArray['wpmuEmailMessage2'] = apply_filters('wppb_register_send_notification_email_success', $registerFilterArray['wpmuEmailMessage2']); echo $registerFilterArray['wpmuEmailMessage2']; } else { $registerFilterArray['emailMessage2'] = '<p class="success">' . __('An email containing the username and password was successfully sent.', 'profilebuilder') . '</p><!-- .success -->'; $registerFilterArray['emailMessage2'] = apply_filters('wppb_register_send_notification_email_success', $registerFilterArray['emailMessage2']); echo $registerFilterArray['emailMessage2']; } } } } else { if ($error) { $registerFilterArray['errorMessage'] = '<p class="error">' . $error . '</p><!-- .error -->'; $registerFilterArray['errorMessage'] = apply_filters('wppb_register_error_messaging', $registerFilterArray['errorMessage'], $error); echo $registerFilterArray['errorMessage']; } if (current_user_can('create_users') && $registration) { $registerFilterArray['alertMessage1'] = '<p class="alert">' . __('Users can register themselves or you can manually create users here.', 'profilebuilder') . '</p><!-- .alert -->'; $registerFilterArray['alertMessage1'] = apply_filters('wppb_register_alert_messaging1', $registerFilterArray['alertMessage1']); echo $registerFilterArray['alertMessage1']; } elseif (current_user_can('create_users')) { $registerFilterArray['alertMessage2'] = '<p class="alert">' . __('Users cannot currently register themselves, but you can manually create users here.', 'profilebuilder') . '</p><!-- .alert -->'; $registerFilterArray['alertMessage2'] = apply_filters('wppb_register_alert_messaging2', $registerFilterArray['alertMessage2']); echo $registerFilterArray['alertMessage2']; } elseif (!current_user_can('create_users') && !$registration) { $registerFilterArray['alertMessage3'] = '<p class="alert">' . __('Only an administrator can add new users.', 'profilebuilder') . '</p><!-- .alert -->'; $registerFilterArray['alertMessage3'] = apply_filters('wppb_register_alert_messaging3', $registerFilterArray['alertMessage3']); echo $registerFilterArray['alertMessage3']; } if ($registration || current_user_can('create_users')) { /* use this action hook to add extra content before the register form. */ do_action('wppb_before_register_fields'); ?> <form enctype="multipart/form-data" method="post" id="adduser" class="user-forms" action="http://<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?> "> <?php echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE . '" /><!-- set the MAX_FILE_SIZE to the server\'s current max upload size in bytes -->'; $registerFilterArray2['name1'] = '<p class="registerNameHeading"><strong>' . __('Name', 'profilebuilder') . '</strong></p>'; $registerFilterArray2['name1'] = apply_filters('wppb_register_content_name1', $registerFilterArray2['name1']); if ($wppb_defaultOptions['username'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['usernameRequired'] == 'yes') { $errorMark = '<font color="red" title="This field is required for registration.">*</font>'; if (isset($_POST['user_name'])) { if (trim($_POST['user_name']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { if ($wppb_defaultOptions['email'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['emailRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['email'])) { if (trim($_POST['email']) == '' || !is_email(trim($_POST['email']))) { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['email'])) { $localVar = $_POST['email']; } $registerFilterArray2['name2'] = ' <p class="form-email' . $errorVar . '"> <label for="email">' . __('E-mail', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="email" type="text" id="email" value="' . trim($localVar) . '" /> </p><!-- .form-email -->'; $registerFilterArray2['name2'] = apply_filters('wppb_register_content_name2_with_email', $registerFilterArray2['name2'], trim($localVar), $errorVar, $errorMark); } } else { $localVar = ''; if (isset($_POST['user_name'])) { $localVar = $_POST['user_name']; } $registerFilterArray2['name2'] = ' <p class="form-username' . $errorVar . '"> <label for="user_name">' . __('Username', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="user_name" type="text" id="user_name" value="' . trim($localVar) . '" /> </p><!-- .form-username -->'; $registerFilterArray2['name2'] = apply_filters('wppb_register_content_name2', $registerFilterArray2['name2'], trim($localVar), $errorVar, $errorMark); } } if ($wppb_defaultOptions['firstname'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['firstnameRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['first_name'])) { if (trim($_POST['first_name']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['first_name'])) { $localVar = $_POST['first_name']; } $registerFilterArray2['name3'] = ' <p class="first_name' . $errorVar . '"> <label for="first_name">' . __('First Name', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="first_name" type="text" id="first_name" value="' . trim($localVar) . '" /> </p><!-- .first_name -->'; $registerFilterArray2['name3'] = apply_filters('wppb_register_content_name3', $registerFilterArray2['name3'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['lastname'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['lastnameRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['last_name'])) { if (trim($_POST['last_name']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['last_name'])) { $localVar = $_POST['last_name']; } $registerFilterArray2['name4'] = ' <p class="last_name' . $errorVar . '"> <label for="last_name">' . __('Last Name', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="last_name" type="text" id="last_name" value="' . trim($localVar) . '" /> </p><!-- .last_name -->'; $registerFilterArray2['name4'] = apply_filters('wppb_register_content_name4', $registerFilterArray2['name4'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['nickname'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['nicknameRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['nickname'])) { if (trim($_POST['nickname']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['nickname'])) { $localVar = $_POST['nickname']; } $registerFilterArray2['name5'] = ' <p class="nickname' . $errorVar . '"> <label for="nickname">' . __('Nickname', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="nickname" type="text" id="nickname" value="' . trim($localVar) . '" /> </p><!-- .nickname -->'; $registerFilterArray2['name5'] = apply_filters('wppb_register_content_name5', $registerFilterArray2['name5'], trim($localVar), $errorVar, $errorMark); } $registerFilterArray2['info1'] = '<p class="registerContactInfoHeading"><strong>' . __('Contact Info', 'profilebuilder') . '</strong></p>'; $registerFilterArray2['info1'] = apply_filters('wppb_register_content_info1', $registerFilterArray2['info1']); if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { } else { if ($wppb_defaultOptions['email'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['emailRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['email'])) { if (trim($_POST['email']) == '' || !is_email(trim($_POST['email']))) { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['email'])) { $localVar = $_POST['email']; } $registerFilterArray2['info2'] = ' <p class="form-email' . $errorVar . '"> <label for="email">' . __('E-mail', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="email" type="text" id="email" value="' . trim($localVar) . '" /> </p><!-- .form-email -->'; $registerFilterArray2['info2'] = apply_filters('wppb_register_content_info2', $registerFilterArray2['info2'], trim($localVar), $errorVar, $errorMark); } } if ($wppb_defaultOptions['website'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['websiteRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['website'])) { if (trim($_POST['website']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['website'])) { $localVar = $_POST['website']; } $registerFilterArray2['info3'] = ' <p class="form-website' . $errorVar . '"> <label for="website">' . __('Website', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="website" type="text" id="website" value="' . trim($localVar) . '" /> </p><!-- .form-website -->'; $registerFilterArray2['info3'] = apply_filters('wppb_register_content_info3', $registerFilterArray2['info3'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['aim'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['aimRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['aim'])) { if (trim($_POST['aim']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['aim'])) { $localVar = $_POST['aim']; } $registerFilterArray2['info4'] = ' <p class="form-aim' . $errorVar . '"> <label for="aim">' . __('AIM', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="aim" type="text" id="aim" value="' . trim($localVar) . '" /> </p><!-- .form-aim -->'; $registerFilterArray2['info4'] = apply_filters('wppb_register_content_info4', $registerFilterArray2['info4'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['yahoo'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['yahooRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['yim'])) { if (trim($_POST['yim']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['yim'])) { $localVar = $_POST['yim']; } $registerFilterArray2['info5'] = ' <p class="form-yim' . $errorVar . '"> <label for="yim">' . __('Yahoo IM', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="yim" type="text" id="yim" value="' . trim($localVar) . '" /> </p><!-- .form-yim -->'; $registerFilterArray2['info5'] = apply_filters('wppb_register_content_info5', $registerFilterArray2['info5'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['jabber'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['jabberRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['jabber'])) { if (trim($_POST['jabber']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['jabber'])) { $localVar = $_POST['jabber']; } $registerFilterArray2['info6'] = ' <p class="form-jabber' . $errorVar . '"> <label for="jabber">' . __('Jabber / Google Talk', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="jabber" type="text" id="jabber" value="' . trim($localVar) . '" /> </p><!-- .form-jabber -->'; $registerFilterArray2['info6'] = apply_filters('wppb_register_content_info6', $registerFilterArray2['info6'], trim($localVar), $errorVar, $errorMark); } $registerFilterArray2['ay1'] = '<p class="registerAboutYourselfHeader"><strong>' . __('About Yourself', 'profilebuilder') . '</strong></p>'; $registerFilterArray2['ay1'] = apply_filters('wppb_register_content_about_yourself1', $registerFilterArray2['ay1']); if ($wppb_defaultOptions['bio'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['bioRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['description'])) { if (trim($_POST['description']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="' . __('This field must be filled out before registering (It was marked as required by the administrator)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['description'])) { $localVar = $_POST['description']; } $registerFilterArray2['ay2'] = ' <p class="form-description' . $errorVar . '"> <label for="description">' . __('Biographical Info', 'profilebuilder') . $errorMark . '</label> <textarea class="text-input" name="description" id="description" rows="5" cols="30">' . trim($localVar) . '</textarea> </p><!-- .form-description -->'; $registerFilterArray2['ay2'] = apply_filters('wppb_register_content_about_yourself2', $registerFilterArray2['ay2'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['password'] == 'show') { $errorMark = ''; $errorMark2 = ''; $errorVar = ''; $errorVar2 = ''; if ($wppb_defaultOptions['passwordRequired'] == 'yes') { $errorMark = '<font color="red" title="This field is required for registration.">*</font>'; $errorMark2 = '<font color="red" title="This field is required for registration.">*</font>'; if (isset($_POST['passw1'])) { if (trim($_POST['passw1']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>'; $errorVar = ' errorHolder'; } } if (isset($_POST['passw2'])) { if (trim($_POST['passw2']) == '') { $errorMark2 = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>'; $errorVar2 = ' errorHolder'; } } } $localVar1 = ''; if (isset($_POST['passw1'])) { $localVar1 = $_POST['passw1']; } $localVar2 = ''; if (isset($_POST['passw2'])) { $localVar2 = $_POST['passw2']; } $registerFilterArray2['ay3'] = ' <p class="form-password' . $errorVar . '"> <label for="pass1">' . __('Password', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="passw1" type="password" id="pass1" value="' . trim($localVar1) . '" /> </p><!-- .form-password --> <p class="form-password' . $errorVar2 . '"> <label for="pass2">' . __('Repeat Password', 'profilebuilder') . $errorMark2 . '</label> <input class="text-input" name="passw2" type="password" id="pass2" value="' . trim($localVar2) . '" /> </p><!-- .form-password -->'; $registerFilterArray2['ay3'] = apply_filters('wppb_register_content_about_yourself3', $registerFilterArray2['ay3'], trim($localVar1), trim($localVar2), $errorVar, $errorMark, $errorVar2, $errorMark2); } $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { require_once $wppb_premium . 'extra.fields.php'; //register_user_extra_fields($error, $_POST, $extraFieldsErrorHolder); $page = 'register'; $returnedValue = wppb_extra_fields($current_user->id, $extraFieldsErrorHolder, $registerFilterArray, $page, $error, $_POST); //copy over extra fields to the rest of the fieldso on the edit profile foreach ($returnedValue as $key => $value) { $registerFilterArray2[$key] = apply_filters('wppb_register_content_' . $key, $value); } } if (function_exists('wppb_add_recaptcha_to_registration_form')) { $wppb_addon_settings = get_option('wppb_addon_settings'); if ($wppb_addon_settings['wppb_reCaptcha'] == 'show') { $reCAPTCHAForm = wppb_add_recaptcha_to_registration_form(); $labelName = apply_filters('wppb_register_anti_spam_title', __('Anti-Spam', 'profilebuilder')); $registerFilterArray2['reCAPTCHAForm'] = '<div class="form-reCAPTCHA"><label class="form-reCAPTCHA-label" for="' . $labelName . '">' . $labelName . '</label>' . $reCAPTCHAForm . '</div><!-- .form-reCAPTCHA -->'; } } // additional filter, just in case it is needed $registerFilterArray2['extraRegistrationFilter'] = ''; $registerFilterArray2['extraRegistrationFilter'] = apply_filters('extraRegistrationField', $registerFilterArray2['extraRegistrationFilter']); // END additional filter, just in case it is needed $wppb_generalSettings = get_option('wppb_general_settings'); if ($wppb_generalSettings['emailConfirmation'] != 'yes') { if (!is_multisite()) { if (isset($_POST['send_credentials_via_email'])) { $checkedVar = ' checked'; } else { $checkedVar = ''; } $registerFilterArray2['confirmationEmailForm'] = ' <p class="send-confirmation-email"> <label for="send-confirmation-email"> <input id="send_credentials_via_email" type="checkbox" name="send_credentials_via_email" value="sending"' . $checkedVar . '/> ' . __('Send these credentials via email.', 'profilebuilder') . ' </label> </p><!-- .send-confirmation-email -->'; $registerFilterArray2['confirmationEmailForm'] = apply_filters('wppb_register_confirmation_email_form', $registerFilterArray2['confirmationEmailForm'], $checkedVar); } } $registerFilterArray2 = apply_filters('wppb_register', $registerFilterArray2); foreach ($registerFilterArray2 as $key => $value) { echo $value; } ?> <p class="form-submit"> <input name="adduser" type="submit" id="addusersub" class="submit button" value="<?php if (current_user_can('create_users')) { _e('Add User', 'profilebuilder'); } else { _e('Register', 'profilebuilder'); } ?> " /> <input name="action" type="hidden" id="action" value="adduser" /> <input type="hidden" name="formName" value="register" /> </p><!-- .form-submit --> <?php wp_nonce_field('verify_true_registration', 'register_nonce_field'); ?> </form><!-- #adduser --> <?php } } /* use this action hook to add extra content after the register form. */ do_action('wppb_after_register_fields'); ?> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function wppb_decode_extraTag($tagName) { //filter to get current user by either username or id(default); get user by username? $userlistingFilterArray['getUserByID'] = false; $userlistingFilterArray['getUserByID'] = apply_filters('wppb_userlisting_get_user_by_id', $userlistingFilterArray['getUserByID']); //get user ID if (isset($_GET['userID'])) { $user = get_userdata($_GET['userID']); $username = $user->user_login; } else { if ($userlistingFilterArray['getUserByID'] === false) { $userID = get_query_var('username'); $user = get_userdata($userID); $username = $user->user_login; } else { $username = get_query_var('username'); } } $user = get_user_by('login', $username); if ($user->ID == null) { return ''; } if ($tagName == 'extra_go_back_link') { $textLink2 = apply_filters('wppb_userlisting_go_back_link_type', true); if ($textLink2) { return $userlistingFilterArray['backLink1'] = apply_filters('wppb_userlisting_go_back_link', '<div id="wppb-back-span" class="wppb-back-span"><a href=\'javascript:history.go(-1)\' class="wppb-back" id="wppb-back" title="' . __('Click here to go back', 'profilebuilder') . '" alt="' . __('Back', 'profilebuilder') . '">' . __('Back', 'profilebuilder') . '</a></div>'); } else { return $userlistingFilterArray['backLink2'] = apply_filters('wppb_userlisting_go_back_link_with_arrow', '<a href=\'javascript:history.go(-1)\' class="wppb-back"><img src="' . WPPB_PLUGIN_URL . '/assets/images/arrow_left.png" title="' . __('Click here to go back', 'profilebuilder') . '" alt="<"/></a>'); } } elseif ($tagName == 'extra_avatar_or_gravatar') { $customUserListingSettings = get_option('customUserListingSettings', 'not_found'); $avatarSizeSingle = apply_filters('wppb_userlisting_avatar_size_single_userlisting', $customUserListingSettings['avatarSizeSingle']); $avatarImage = get_avatar($user->ID, $avatarSize); return $userData = apply_filters('wppb_userlisting_extra_avatar_or_gravatar_single_userlisting', $avatarImage, $user, $avatarSizeSingle); } elseif ($tagName == 'meta_user_name') { $userData = get_the_author_meta('user_login', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_user_name', $userData, $user); } elseif ($tagName == 'meta_email') { $userData = get_the_author_meta('user_email', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_email', $userData, $user); } elseif ($tagName == 'meta_first_name') { $userData = get_the_author_meta('first_name', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_first_name', $userData, $user); } elseif ($tagName == 'meta_first_last_name') { $userData1 = get_the_author_meta('first_name', $user->ID); $userData2 = get_the_author_meta('last_name', $user->ID); if ($userData1 != '' && $userData2 != '') { $userData = $userData1 . ' ' . $userData2; } elseif ($userData1 == '') { $userData = $userData2; } elseif ($userData2 == '') { $userData = $userData1; } else { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_first_last_name_single_userlisting', $userData, $user); } elseif ($tagName == 'meta_last_name') { $userData = get_the_author_meta('last_name', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_last_name', $userData, $user); } elseif ($tagName == 'meta_nickname') { $userData = get_the_author_meta('nickname', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_nickname', $userData, $user); } elseif ($tagName == 'meta_display_name') { $userData = get_the_author_meta('display_name', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_display_name', $userData, $user); } elseif ($tagName == 'meta_number_of_posts') { $args = array('author' => $user->ID, 'numberposts' => -1); $allPosts = get_posts($args); $postsNumber = count($allPosts); return $userData = apply_filters('wppb_userlisting_extra_meta_number_of_posts_single_userlisting', '<a href="' . get_author_posts_url($user->ID) . '" id="postNumberLinkSingle" class="postNumberLinkSingle">' . $postsNumber . '</a>', $user, $postsNumber); } elseif ($tagName == 'meta_website') { $userData = get_the_author_meta('user_url', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_website', $userData, $user); } elseif ($tagName == 'meta_aim') { $userData = get_the_author_meta('aim', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_aim', $userData, $user); } elseif ($tagName == 'meta_yim') { $userData = get_the_author_meta('yim', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_yim', $userData, $user); } elseif ($tagName == 'meta_jabber') { $userData = get_the_author_meta('jabber', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_jabber', $userData, $user); } elseif ($tagName == 'meta_role') { if (isset($GLOBALS['wp_roles']->roles[$user->roles[0]])) { $role = $GLOBALS['wp_roles']->roles[$user->roles[0]]['name']; } else { $role = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_role_single_userlisting', $role, $user); } elseif ($tagName == 'meta_biographical_info') { $userData = get_the_author_meta('description', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_biographical_info', $userData, $user); } elseif ($tagName == 'meta_registration_date') { $time = date("n/j/Y", strtotime($user->user_registered)); return $userData = apply_filters('wppb_userlisting_extra_meta_tag_registration_date', $time, $user); } else { global $wppbFetchArray; if (count($wppbFetchArray) >= 1) { foreach ($wppbFetchArray as $key => $value) { if ('meta_' . $value['item_metaName'] == $tagName) { switch ($value['item_type']) { case "input": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "checkbox": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData != '') { $userDataArray = explode(',', $userData); $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']); $newValue = str_replace(' ', '#@space@#', $value['item_options']); //we need to escape the spaces in the options list, because it won't save $checkboxValue = explode(',', $value['item_options']); $checkboxValue2 = explode(',', $newValue); $nr = count($userDataArray); $userData = ''; for ($i = 0; $i < $nr - 2; $i++) { $userData .= $userDataArray[$i] . ', '; } $userData .= $userDataArray[$nr - 2]; } else { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "radio": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "select": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "countrySelect": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "timeZone": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "datepicker": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "textarea": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData != '') { $userData = nl2br($userData); } else { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "upload": $imgSource = WPPB_PLUGIN_URL . '/assets/images/'; $script = WPPB_PLUGIN_URL . '/premium/functions/'; $userData = get_user_meta($user->ID, $value['item_metaName'], true); $fileName = str_replace(get_bloginfo('home') . '/wp-content/uploads/profile_builder/attachments/userID_' . $user->ID . '_attachment_', '', $userData); if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/attachments/') { $retUserData = '<span class="wppb-description-delimiter2"><u>' . __('Current file', 'profilebuilder') . '</u>: </span><span class="wppb-description-delimiter2">' . __('No uploaded attachment', 'profilebuilder') . '</span>'; } else { $retUserData = '<span class="wppb-description-delimiter2"><u>' . __('Current file', 'profilebuilder') . '</u>: ' . $fileName . '<a href="' . $userData . '" target="_blank" class="wppb-cattachment"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current attachment', 'profilebuilder') . '"></a></span>'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $retUserData, $user); case "avatar": $imgSource = WPPB_PLUGIN_URL . '/assets/images/'; $userData = get_user_meta($user->ID, $value['item_metaName'], true); // to use for the link $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview //this checks if it only has 1 component if (is_numeric($value['item_options'])) { $width = $height = $value['item_options']; //this checks if the entered value has 2 components } else { $sentValue = explode(',', $value['item_options']); $width = $sentValue[0]; $height = $sentValue[1]; } if ($userData != '') { if ($userData2 == '') { wppb_resize_avatar($user->ID); $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview } $imgRelativePath = get_user_meta($user->ID, 'resized_avatar_' . $value['id'] . '_relative_path', true); //get relative path //get image info $info = getimagesize($imgRelativePath); //this checks if it only has 1 component if (is_numeric($item_options)) { $width = $height = $item_options; //this checks if the entered value has 2 components } else { $sentValue = explode(',', $item_options); $width = $sentValue[0]; $height = $sentValue[1]; } //call the avatar resize function if needed if ($info[0] != $width || $info[1] != $height) { wppb_resize_avatar($user->ID); //re-fetch user-data $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview } if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/avatars/') { return $avatarImage = get_avatar($user->ID, $value['item_options']); } else { // display the resized image $retUserData = '<span class="avatar-border"><IMG SRC="' . $userData2 . '" TITLE="' . __('Avatar', 'profilebuilder') . '" ALT="' . __('Avatar', 'profilebuilder') . '" HEIGHT=' . $info[1] . ' WIDTH=' . $info[0] . '></span>'; // display a link to the bigger image to see it clearly return $retUserData .= '<a href="' . $userData . '" target="_blank" class="wppb-cattachment"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current attachment', 'profilebuilder') . '"></a>'; } } else { return $avatarImage = get_avatar($user->ID, $width); } } } elseif ('meta_description_' . $value['item_metaName'] == $tagName) { return $value['item_desc']; } elseif ('meta_' . $value['item_metaName'] . '_URL' == $tagName) { switch ($value['item_type']) { case "upload": $userData = get_user_meta($user->ID, $value['item_metaName'], true); $fileName = str_replace(get_bloginfo('home') . '/wp-content/uploads/profile_builder/attachments/userID_' . $user->ID . '_attachment_', '', $userData); if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/attachments/') { return $userData = apply_filters('wppb_userlisting_extra_meta_' . $value['item_metaName'] . '_url_empty_single', $userData, $object); } else { return $userData = apply_filters('wppb_userlisting_extra_meta_' . $value['item_metaName'] . '_url_single', $userData, $object); } } } elseif ('meta_' . $value['item_title'] == $tagName) { //fall-back switch ($value['item_type']) { case "input": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "checkbox": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData != '') { $userDataArray = explode(',', $userData); $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']); $newValue = str_replace(' ', '#@space@#', $value['item_options']); //we need to escape the spaces in the options list, because it won't save $checkboxValue = explode(',', $value['item_options']); $checkboxValue2 = explode(',', $newValue); $nr = count($userDataArray); $userData = ''; for ($i = 0; $i < $nr - 2; $i++) { $userData .= $userDataArray[$i] . ', '; } $userData .= $userDataArray[$nr - 2]; } else { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "radio": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "select": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "countrySelect": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "timeZone": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "datepicker": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "textarea": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData != '') { $userData = nl2br($userData); } else { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "upload": $imgSource = WPPB_PLUGIN_URL . '/assets/images/'; $script = WPPB_PLUGIN_URL . '/premium/functions/'; $userData = get_user_meta($user->ID, $value['item_metaName'], true); $fileName = str_replace(get_bloginfo('home') . '/wp-content/uploads/profile_builder/attachments/userID_' . $user->ID . '_attachment_', '', $userData); if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/attachments/') { $retUserData = '<span class="wppb-description-delimiter2"><u>' . __('Current file', 'profilebuilder') . '</u>: </span><span class="wppb-description-delimiter2">' . __('No uploaded attachment', 'profilebuilder') . '</span>'; } else { $retUserData = '<span class="wppb-description-delimiter2"><u>' . __('Current file', 'profilebuilder') . '</u>: ' . $fileName . '<a href="' . $userData . '" target="_blank" class="wppb-cattachment"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current attachment', 'profilebuilder') . '"></a></span>'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $retUserData, $user); case "avatar": $imgSource = WPPB_PLUGIN_URL . '/assets/images/'; $userData = get_user_meta($user->ID, $value['item_metaName'], true); // to use for the link $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview //this checks if it only has 1 component if (is_numeric($value['item_options'])) { $width = $height = $value['item_options']; //this checks if the entered value has 2 components } else { $sentValue = explode(',', $value['item_options']); $width = $sentValue[0]; $height = $sentValue[1]; } if ($userData != '') { if ($userData2 == '') { wppb_resize_avatar($user->ID); $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview } $imgRelativePath = get_user_meta($user->ID, 'resized_avatar_' . $value['id'] . '_relative_path', true); //get relative path //get image info $info = getimagesize($imgRelativePath); //this checks if it only has 1 component if (is_numeric($item_options)) { $width = $height = $item_options; //this checks if the entered value has 2 components } else { $sentValue = explode(',', $item_options); $width = $sentValue[0]; $height = $sentValue[1]; } //call the avatar resize function if needed if ($info[0] != $width || $info[1] != $height) { wppb_resize_avatar($user->ID); //re-fetch user-data $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview } if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/avatars/') { return $avatarImage = get_avatar($user->ID, $value['item_options']); } else { // display the resized image $retUserData = '<span class="avatar-border"><IMG SRC="' . $userData2 . '" TITLE="' . __('Avatar', 'profilebuilder') . '" ALT="' . __('Avatar', 'profilebuilder') . '" HEIGHT=' . $info[1] . ' WIDTH=' . $info[0] . '></span>'; // display a link to the bigger image to see it clearly return $retUserData .= '<a href="' . $userData . '" target="_blank" class="wppb-cattachment"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current attachment', 'profilebuilder') . '"></a>'; } } else { return $avatarImage = get_avatar($user->ID, $width); } } } elseif ('meta_description_' . $value['item_title'] == $tagName) { return $value['item_desc']; } } } } }