Beispiel #1
0
    function edit_field($key, $data, $rule = false)
    {
        global $ultimatemember;
        $output = null;
        // get whole field data
        if (isset($data) && is_array($data)) {
            $data = $this->get_field($key);
            extract($data);
        }
        if (!isset($data['type'])) {
            return;
        }
        if (isset($data['in_group']) && $data['in_group'] != '' && $rule != 'group') {
            return;
        }
        if ($visibility == 'view') {
            return;
        }
        if (!um_can_view_field($data)) {
            return;
        }
        if (!um_can_edit_field($data)) {
            return;
        }
        // fields that need to be disabled in edit mode (profile)
        if (in_array($key, array('user_email', 'username', 'user_login', 'user_password')) && $this->editing == true && $this->set_mode == 'profile') {
            return;
        }
        // forbidden in edit mode?
        if (isset($data['edit_forbidden'])) {
            return;
        }
        // required option
        if (isset($data['required_opt'])) {
            $opt = $data['required_opt'];
            if (um_get_option($opt[0]) != $opt[1]) {
                return;
            }
        }
        // required user permission
        if (isset($data['required_perm'])) {
            if (!um_user($data['required_perm'])) {
                return;
            }
        }
        // do not show passwords
        if (isset($ultimatemember->user->preview) && $ultimatemember->user->preview) {
            if ($data['type'] == 'password') {
                return;
            }
        }
        /* Begin by field type */
        switch ($type) {
            /* Default: Integration */
            default:
                $mode = isset($this->set_mode) ? $this->set_mode : 'no_mode';
                $output .= apply_filters("um_edit_field_{$mode}_{$type}", $output, $data);
                break;
                /* Other fields */
            /* Other fields */
            case 'googlemap':
            case 'youtube_video':
            case 'vimeo_video':
            case 'soundcloud_track':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                if (isset($icon) && $icon && isset($this->field_icons) && $this->field_icons == 'field') {
                    $output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
                }
                $output .= '<input ' . $disabled . ' class="' . $this->get_class($key, $data) . '" type="' . $input . '" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . htmlspecialchars($this->field_value($key, $default, $data)) . '" placeholder="' . $placeholder . '" data-validate="' . $validate . '" data-key="' . $key . '" />
							
						</div>';
                if ($this->is_error($key)) {
                    $output .= $this->field_error($this->show_error($key));
                }
                $output .= '</div>';
                break;
                /* Text */
            /* Text */
            case 'text':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                if (isset($icon) && $icon && isset($this->field_icons) && $this->field_icons == 'field') {
                    $output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
                }
                $output .= '<input ' . $disabled . ' class="' . $this->get_class($key, $data) . '" type="' . $input . '" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . htmlspecialchars($this->field_value($key, $default, $data)) . '" placeholder="' . $placeholder . '" data-validate="' . $validate . '" data-key="' . $key . '" />
							
						</div>';
                if ($this->is_error($key)) {
                    $output .= $this->field_error($this->show_error($key));
                }
                $output .= '</div>';
                break;
                /* Password */
            /* Password */
            case 'password':
                $original_key = $key;
                if ($key == 'single_user_password') {
                    $key = $original_key;
                    $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                    if (isset($data['label'])) {
                        $output .= $this->field_label($label, $key, $data);
                    }
                    $output .= '<div class="um-field-area">';
                    if (isset($icon) && $icon && $this->field_icons == 'field') {
                        $output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
                    }
                    $output .= '<input class="' . $this->get_class($key, $data) . '" type="' . $input . '" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . $this->field_value($key, $default, $data) . '" placeholder="' . $placeholder . '" data-validate="' . $validate . '" data-key="' . $key . '" />
								
							</div>';
                    if ($this->is_error($key)) {
                        $output .= $this->field_error($this->show_error($key));
                    }
                    $output .= '</div>';
                } else {
                    if ($this->set_mode == 'account' && um_is_core_page('account')) {
                        $key = 'current_' . $original_key;
                        $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                        if (isset($data['label'])) {
                            $output .= $this->field_label(__('Current Password', 'ultimatemember'), $key, $data);
                        }
                        $output .= '<div class="um-field-area">';
                        if (isset($icon) && $icon && $this->field_icons == 'field') {
                            $output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
                        }
                        $output .= '<input class="' . $this->get_class($key, $data) . '" type="' . $input . '" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . $this->field_value($key, $default, $data) . '" placeholder="' . $placeholder . '" data-validate="' . $validate . '" data-key="' . $key . '" />
									
								</div>';
                        if ($this->is_error($key)) {
                            $output .= $this->field_error($this->show_error($key));
                        }
                        $output .= '</div>';
                    }
                    $key = $original_key;
                    $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                    if ($this->set_mode == 'account' && um_is_core_page('account') || $this->set_mode == 'password' && um_is_core_page('password-reset')) {
                        $output .= $this->field_label(__('New Password', 'ultimatemember'), $key, $data);
                    } else {
                        if (isset($data['label'])) {
                            $output .= $this->field_label($label, $key, $data);
                        }
                    }
                    $output .= '<div class="um-field-area">';
                    if (isset($icon) && $icon && $this->field_icons == 'field') {
                        $output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
                    }
                    $output .= '<input class="' . $this->get_class($key, $data) . '" type="' . $input . '" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . $this->field_value($key, $default, $data) . '" placeholder="' . $placeholder . '" data-validate="' . $validate . '" data-key="' . $key . '" />
							
						</div>';
                    if ($this->is_error($key)) {
                        $output .= $this->field_error($this->show_error($key));
                    }
                    $output .= '</div>';
                    if ($this->set_mode != 'login' && isset($data['force_confirm_pass']) && $data['force_confirm_pass'] == 1) {
                        $key = 'confirm_' . $original_key;
                        $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                        if (isset($data['label'])) {
                            $output .= $this->field_label(sprintf(__('Confirm %s', 'ultimatemember'), $data['label']), $key, $data);
                        }
                        $output .= '<div class="um-field-area">';
                        if (isset($icon) && $icon && $this->field_icons == 'field') {
                            $output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
                        }
                        $output .= '<input class="' . $this->get_class($key, $data) . '" type="' . $input . '" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . $this->field_value($key, $default, $data) . '" placeholder="' . $placeholder . '" data-validate="' . $validate . '" data-key="' . $key . '" />
									
								</div>';
                        if ($this->is_error($key)) {
                            $output .= $this->field_error($this->show_error($key));
                        }
                        $output .= '</div>';
                    }
                }
                break;
                /* URL */
            /* URL */
            case 'url':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                if (isset($icon) && $icon && isset($this->field_icons) && $this->field_icons == 'field') {
                    $output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
                }
                $output .= '<input class="' . $this->get_class($key, $data) . '" type="' . $input . '" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . $this->field_value($key, $default, $data) . '" placeholder="' . $placeholder . '" data-validate="' . $validate . '" data-key="' . $key . '" />
							
						</div>';
                if ($this->is_error($key)) {
                    $output .= $this->field_error($this->show_error($key));
                }
                $output .= '</div>';
                break;
                /* Date */
            /* Date */
            case 'date':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                if (isset($icon) && $icon && isset($this->field_icons) && $this->field_icons == 'field') {
                    $output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
                }
                $output .= '<input class="' . $this->get_class($key, $data) . '" type="' . $input . '" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . $this->field_value($key, $default, $data) . '" placeholder="' . $placeholder . '" data-validate="' . $validate . '" data-key="' . $key . '"    data-range="' . $range . '" data-years="' . $years . '" data-years_x="' . $years_x . '" data-disabled_weekdays="' . $disabled_weekdays . '" data-date_min="' . $date_min . '" data-date_max="' . $date_max . '" data-format="' . $js_format . '" data-value="' . $this->field_value($key, $default, $data) . '" />
							
						</div>';
                if ($this->is_error($key)) {
                    $output .= $this->field_error($this->show_error($key));
                }
                $output .= '</div>';
                break;
                /* Time */
            /* Time */
            case 'time':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                if (isset($icon) && $icon && $this->field_icons == 'field') {
                    $output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
                }
                $output .= '<input class="' . $this->get_class($key, $data) . '" type="' . $input . '" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . $this->field_value($key, $default, $data) . '" placeholder="' . $placeholder . '" data-validate="' . $validate . '" data-key="' . $key . '"  data-format="' . $js_format . '" data-intervals="' . $intervals . '" data-value="' . $this->field_value($key, $default, $data) . '" />
							
						</div>';
                if ($this->is_error($key)) {
                    $output .= $this->field_error($this->show_error($key));
                }
                $output .= '</div>';
                break;
                /* Row */
            /* Row */
            case 'row':
                $output .= '';
                break;
                /* Textarea */
            /* Textarea */
            case 'textarea':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                $output .= '<textarea style="height: ' . $height . ';" class="' . $this->get_class($key, $data) . '" name="' . $key . '" id="' . $key . '" placeholder="' . $placeholder . '">' . $this->field_value($key, $default, $data) . '</textarea>
							
						</div>';
                if ($this->is_error($key)) {
                    $output .= $this->field_error($this->show_error($key));
                }
                $output .= '</div>';
                break;
                /* Rating */
            /* Rating */
            case 'rating':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                $output .= '<div class="um-rating um-raty" id="' . $key . '" data-key="' . $key . '" data-number="' . $data['number'] . '" data-score="' . $this->field_value($key, $default, $data) . '"></div>';
                $output .= '</div>';
                $output .= '</div>';
                break;
                /* Gap/Space */
            /* Gap/Space */
            case 'spacing':
                $output .= '<div class="um-field um-field-spacing' . $classes . '"' . $conditional . ' style="height: ' . $spacing . '"></div>';
                break;
                /* A line divider */
            /* A line divider */
            case 'divider':
                $output .= '<div class="um-field um-field-divider' . $classes . '"' . $conditional . ' style="border-bottom: ' . $borderwidth . 'px ' . $borderstyle . ' ' . $bordercolor . '">';
                if ($divider_text) {
                    $output .= '<div class="um-field-divider-text"><span>' . $divider_text . '</span></div>';
                }
                $output .= '</div>';
                break;
                /* Single Image Upload */
            /* Single Image Upload */
            case 'image':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (in_array($key, array('profile_photo', 'cover_photo'))) {
                    $field_value = '';
                } else {
                    $field_value = $this->field_value($key, $default, $data);
                }
                $output .= '<input type="hidden" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . $field_value . '" />';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $modal_label = isset($data['label']) ? $data['label'] : __('Upload Photo', 'ultimatemember');
                $output .= '<div class="um-field-area" style="text-align: center">';
                if ($this->field_value($key, $default, $data)) {
                    if (!in_array($key, array('profile_photo', 'cover_photo'))) {
                        if (isset($this->set_mode) && $this->set_mode == 'register') {
                            $imgValue = $this->field_value($key, $default, $data);
                        } else {
                            $imgValue = um_user_uploads_uri() . $this->field_value($key, $default, $data);
                        }
                        $img = '<img src="' . $imgValue . '" alt="" />';
                    } else {
                        $img = '';
                    }
                    $output .= '<div class="um-single-image-preview show ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">
								<a href="#" class="cancel"><i class="um-icon-close"></i></a>' . $img . '
							</div><a href="#" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . __('Change photo', 'ultimatemember') . '</a>';
                } else {
                    $output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-key="' . $key . '">
								<a href="#" class="cancel"><i class="um-icon-close"></i></a>
								<img src="" alt="" />
							</div><a href="#" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . $button_text . '</a>';
                }
                $output .= '</div>';
                /* modal hidden */
                $output .= '<div class="um-modal-hidden-content">';
                $output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
                $output .= '<div class="um-modal-body">';
                if (isset($this->set_id)) {
                    $set_id = $this->set_id;
                    $set_mode = $this->set_mode;
                } else {
                    $set_id = 0;
                    $set_mode = '';
                }
                $output .= '<div class="um-single-image-preview ' . $crop_class . '" data-crop="' . $crop_data . '" data-ratio="' . $ratio . '" data-min_width="' . $min_width . '" data-min_height="' . $min_height . '" data-coord=""><a href="#" class="cancel"><i class="um-icon-close"></i></a><img src="" alt="" /></div>';
                $output .= '<div class="um-single-image-upload" data-icon="' . $icon . '" data-set_id="' . $set_id . '" data-set_mode="' . $set_mode . '" data-type="' . $type . '" data-key="' . $key . '" data-max_size="' . $max_size . '" data-max_size_error="' . $max_size_error . '" data-min_size_error="' . $min_size_error . '" data-extension_error="' . $extension_error . '"  data-allowed_types="' . $allowed_types . '" data-upload_text="' . $upload_text . '" data-max_files_error="' . $max_files_error . '" data-upload_help_text="' . $upload_help_text . '">' . $button_text . '</div>';
                $output .= '<div class="um-modal-footer">
									<div class="um-modal-right">
										<a href="#" class="um-modal-btn um-finish-upload image disabled" data-key="' . $key . '" data-change="' . __('Change photo', 'ultimatemember') . '" data-processing="' . __('Processing...', 'ultimatemember') . '"> ' . __('Apply', 'ultimatemember') . '</a>
										<a href="#" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __('Cancel', 'ultimatemember') . '</a>
									</div>
									<div class="um-clear"></div>
								</div>';
                $output .= '</div>';
                $output .= '</div>';
                /* end */
                if ($this->is_error($key)) {
                    $output .= $this->field_error($this->show_error($key));
                }
                $output .= '</div>';
                break;
                /* Single File Upload */
            /* Single File Upload */
            case 'file':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                $output .= '<input type="hidden" name="' . $key . $ultimatemember->form->form_suffix . '" id="' . $key . $ultimatemember->form->form_suffix . '" value="' . $this->field_value($key, $default, $data) . '" />';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $modal_label = isset($data['label']) ? $data['label'] : __('Upload Photo', 'ultimatemember');
                $output .= '<div class="um-field-area" style="text-align: center">';
                if ($this->field_value($key, $default, $data)) {
                    $extension = pathinfo($this->field_value($key, $default, $data), PATHINFO_EXTENSION);
                    $output .= '<div class="um-single-file-preview show" data-key="' . $key . '">
										<a href="#" class="cancel"><i class="um-icon-close"></i></a>
										<div class="um-single-fileinfo">
											<a href="' . um_user_uploads_uri() . $this->field_value($key, $default, $data) . '" target="_blank">
												<span class="icon" style="background:' . $ultimatemember->files->get_fonticon_bg_by_ext($extension) . '"><i class="' . $ultimatemember->files->get_fonticon_by_ext($extension) . '"></i></span>
												<span class="filename">' . $this->field_value($key, $default, $data) . '</span>
											</a>
										</div>
							</div><a href="#" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . __('Change file', 'ultimatemember') . '</a>';
                } else {
                    $output .= '<div class="um-single-file-preview" data-key="' . $key . '">
							</div><a href="#" data-modal="um_upload_single" data-modal-size="' . $modal_size . '" data-modal-copy="1" class="um-button um-btn-auto-width">' . $button_text . '</a>';
                }
                $output .= '</div>';
                /* modal hidden */
                $output .= '<div class="um-modal-hidden-content">';
                $output .= '<div class="um-modal-header"> ' . $modal_label . '</div>';
                $output .= '<div class="um-modal-body">';
                if (isset($this->set_id)) {
                    $set_id = $this->set_id;
                    $set_mode = $this->set_mode;
                } else {
                    $set_id = 0;
                    $set_mode = '';
                }
                $output .= '<div class="um-single-file-preview">
										<a href="#" class="cancel"><i class="um-icon-close"></i></a>
										<div class="um-single-fileinfo">
											<a href="" target="_blank">
												<span class="icon"><i></i></span>
												<span class="filename"></span>
											</a>
										</div>
								</div>';
                $output .= '<div class="um-single-file-upload" data-icon="' . $icon . '" data-set_id="' . $set_id . '" data-set_mode="' . $set_mode . '" data-type="' . $type . '" data-key="' . $key . '" data-max_size="' . $max_size . '" data-max_size_error="' . $max_size_error . '" data-min_size_error="' . $min_size_error . '" data-extension_error="' . $extension_error . '"  data-allowed_types="' . $allowed_types . '" data-upload_text="' . $upload_text . '" data-max_files_error="' . $max_files_error . '" data-upload_help_text="' . $upload_help_text . '">' . $button_text . '</div>';
                $output .= '<div class="um-modal-footer">
									<div class="um-modal-right">
										<a href="#" class="um-modal-btn um-finish-upload file disabled" data-key="' . $key . '" data-change="' . __('Change file') . '" data-processing="' . __('Processing...', 'ultimatemember') . '"> ' . __('Save', 'ultimatemember') . '</a>
										<a href="#" class="um-modal-btn alt" data-action="um_remove_modal"> ' . __('Cancel', 'ultimatemember') . '</a>
									</div>
									<div class="um-clear"></div>
								</div>';
                $output .= '</div>';
                $output .= '</div>';
                /* end */
                if ($this->is_error($key)) {
                    $output .= $this->field_error($this->show_error($key));
                }
                $output .= '</div>';
                break;
                /* Select dropdown */
            /* Select dropdown */
            case 'select':
                $form_key = str_replace('role_select', 'role', $key);
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['allowclear']) && $data['allowclear'] == 0) {
                    $class = 'um-s2';
                } else {
                    $class = 'um-s1';
                }
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                $output .= '<select name="' . $form_key . '" id="' . $form_key . '" data-validate="' . $validate . '" data-key="' . $key . '" class="' . $this->get_class($key, $data, $class) . '" style="width: 100%" data-placeholder="' . $placeholder . '">';
                if (isset($options) && $options == 'builtin') {
                    $options = $ultimatemember->builtin->get($filter);
                }
                if (!isset($options)) {
                    $options = $ultimatemember->builtin->get('countries');
                }
                // role field
                if ($form_key == 'role') {
                    global $wpdb;
                    foreach ($options as $key => $val) {
                        $val = (string) $val;
                        $val = trim($val);
                        $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'um_role' AND post_title = '{$val}'");
                        $_role = get_post($post_id);
                        $new_roles[$_role->post_name] = $_role->post_title;
                        wp_reset_postdata();
                    }
                    $options = $new_roles;
                }
                // add an empty option!
                $output .= '<option value=""></option>';
                // add options
                foreach ($options as $k => $v) {
                    $v = rtrim($v);
                    if (!is_numeric($k) && in_array($form_key, array('role'))) {
                        $option_value = $k;
                    } else {
                        $option_value = $v;
                    }
                    if (isset($options_pair)) {
                        $option_value = $k;
                    }
                    $output .= '<option value="' . $option_value . '" ';
                    if ($this->is_selected($form_key, $option_value, $data)) {
                        $output .= 'selected';
                    }
                    $output .= '>' . $v . '</option>';
                }
                $output .= '</select>';
                $output .= '</div>';
                if ($this->is_error($form_key)) {
                    $output .= $this->field_error($this->show_error($form_key));
                }
                $output .= '</div>';
                break;
                /* Multi-Select dropdown */
            /* Multi-Select dropdown */
            case 'multiselect':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['allowclear']) && $data['allowclear'] == 0) {
                    $class = 'um-s2';
                } else {
                    $class = 'um-s1';
                }
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                $output .= '<select multiple="multiple" name="' . $key . '[]" id="' . $key . '" data-validate="' . $validate . '" data-key="' . $key . '" class="' . $this->get_class($key, $data, $class) . '" style="width: 100%" data-placeholder="' . $placeholder . '">';
                if (isset($options) && $options == 'builtin') {
                    $options = $ultimatemember->builtin->get($filter);
                }
                if (!isset($options)) {
                    $options = $ultimatemember->builtin->get('countries');
                }
                // add an empty option!
                $output .= '<option value=""></option>';
                // add options
                foreach ($options as $k => $v) {
                    $v = rtrim($v);
                    $output .= '<option value="' . $v . '" ';
                    if ($this->is_selected($key, $v, $data)) {
                        $output .= 'selected';
                    }
                    $output .= '>' . $v . '</option>';
                }
                $output .= '</select>';
                $output .= '</div>';
                if ($this->is_error($key)) {
                    $output .= $this->field_error($this->show_error($key));
                }
                $output .= '</div>';
                break;
                /* Radio */
            /* Radio */
            case 'radio':
                $form_key = str_replace('role_radio', 'role', $key);
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                // role field
                if ($form_key == 'role') {
                    global $wpdb;
                    foreach ($options as $key => $val) {
                        $val = (string) $val;
                        $val = trim($val);
                        $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'um_role' AND post_title = '{$val}'");
                        $_role = get_post($post_id);
                        $new_roles[$_role->post_name] = $_role->post_title;
                        wp_reset_postdata();
                    }
                    $options = $new_roles;
                }
                // add options
                $i = 0;
                foreach ($options as $k => $v) {
                    $v = rtrim($v);
                    if (!is_numeric($k) && in_array($form_key, array('role'))) {
                        $option_value = $k;
                    } else {
                        $option_value = $v;
                    }
                    $i++;
                    if ($i % 2 == 0) {
                        $col_class = 'right';
                    } else {
                        $col_class = '';
                    }
                    if ($this->is_radio_checked($key, $option_value, $data)) {
                        $active = 'active';
                        $class = "um-icon-android-radio-button-on";
                    } else {
                        $active = '';
                        $class = "um-icon-android-radio-button-off";
                    }
                    $output .= '<label class="um-field-radio ' . $active . ' um-field-half ' . $col_class . '">';
                    $output .= '<input type="radio" name="' . $form_key . '" value="' . $option_value . '" ';
                    if ($this->is_radio_checked($key, $option_value, $data)) {
                        $output .= 'checked';
                    }
                    $output .= ' />';
                    $output .= '<span class="um-field-radio-state"><i class="' . $class . '"></i></span>';
                    $output .= '<span class="um-field-radio-option">' . $v . '</span>';
                    $output .= '</label>';
                    if ($i % 2 == 0) {
                        $output .= '<div class="um-clear"></div>';
                    }
                }
                $output .= '<div class="um-clear"></div>';
                $output .= '</div>';
                if ($this->is_error($form_key)) {
                    $output .= $this->field_error($this->show_error($form_key));
                }
                $output .= '</div>';
                break;
                /* Checkbox */
            /* Checkbox */
            case 'checkbox':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
                if (isset($data['label'])) {
                    $output .= $this->field_label($label, $key, $data);
                }
                $output .= '<div class="um-field-area">';
                // add options
                $i = 0;
                foreach ($options as $k => $v) {
                    $v = rtrim($v);
                    $i++;
                    if ($i % 2 == 0) {
                        $col_class = 'right';
                    } else {
                        $col_class = '';
                    }
                    if ($this->is_selected($key, $v, $data)) {
                        $active = 'active';
                        $class = "um-icon-android-checkbox-outline";
                    } else {
                        $active = '';
                        $class = "um-icon-android-checkbox-outline-blank";
                    }
                    $output .= '<label class="um-field-checkbox ' . $active . ' um-field-half ' . $col_class . '">';
                    $output .= '<input type="checkbox" name="' . $key . '[]" value="' . strip_tags($v) . '" ';
                    if ($this->is_selected($key, $v, $data)) {
                        $output .= 'checked';
                    }
                    $output .= ' />';
                    $output .= '<span class="um-field-checkbox-state"><i class="' . $class . '"></i></span>';
                    $output .= '<span class="um-field-checkbox-option">' . $v . '</span>';
                    $output .= '</label>';
                    if ($i % 2 == 0) {
                        $output .= '<div class="um-clear"></div>';
                    }
                }
                $output .= '<div class="um-clear"></div>';
                $output .= '</div>';
                if ($this->is_error($key)) {
                    $output .= $this->field_error($this->show_error($key));
                }
                $output .= '</div>';
                break;
                /* HTML */
            /* HTML */
            case 'block':
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">
								<div class="um-field-block">' . $content . '</div>
							</div>';
                break;
                /* Shortcode */
            /* Shortcode */
            case 'shortcode':
                $content = str_replace('{profile_id}', um_profile_id(), $content);
                $output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">
								<div class="um-field-shortcode">' . do_shortcode($content) . '</div>
							</div>';
                break;
                /* Unlimited Group */
            /* Unlimited Group */
            case 'group':
                $fields = $this->get_fields_in_group($key);
                if (!empty($fields)) {
                    $output .= '<div class="um-field-group" data-max_entries="' . $max_entries . '">
								<div class="um-field-group-head"><i class="um-icon-plus"></i>' . $label . '</div>';
                    $output .= '<div class="um-field-group-body"><a href="#" class="um-field-group-cancel"><i class="um-icon-close"></i></a>';
                    foreach ($fields as $subkey => $subdata) {
                        $output .= $this->edit_field($subkey, $subdata, 'group');
                    }
                    $output .= '</div>';
                    $output .= '</div>';
                }
                break;
        }
        // Custom filter for field output
        if (isset($this->set_mode)) {
            $output = apply_filters("um_{$key}_form_edit_field", $output, $this->set_mode);
        }
        return $output;
    }
function um_get_avatar_uri($image, $attrs)
{
    global $ultimatemember;
    $uri = false;
    $find = false;
    if (file_exists($ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo-' . $attrs . '.jpg')) {
        $uri = um_user_uploads_uri() . 'profile_photo-' . $attrs . '.jpg?' . current_time('timestamp');
    } else {
        $sizes = um_get_option('photo_thumb_sizes');
        if (is_array($sizes)) {
            $find = um_closest_num($sizes, $attrs);
        }
        if (file_exists($ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo-' . $find . '.jpg')) {
            $uri = um_user_uploads_uri() . 'profile_photo-' . $find . '.jpg?' . current_time('timestamp');
        } else {
            if (file_exists($ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo.jpg')) {
                $uri = um_user_uploads_uri() . 'profile_photo.jpg?' . current_time('timestamp');
            }
        }
        if ($attrs == 'original') {
            $uri = um_user_uploads_uri() . 'profile_photo.jpg?' . current_time('timestamp');
        }
    }
    return $uri;
}
function um_profile_field_filter_hook__image($value, $data)
{
    $uri = um_user_uploads_uri() . $value;
    $title = isset($data['title']) ? $data['title'] : __('Untitled photo');
    if (file_exists(um_user_uploads_dir() . $value)) {
        $value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="' . $uri . '"><img src="' . $uri . '" alt="' . $title . '" title="' . $title . '" class="" /></a></div>';
    } else {
        $value = '';
    }
    return $value;
}
function um_profile_dynamic_meta_desc()
{
    global $ultimatemember;
    if (um_is_core_page('user') && um_get_requested_user()) {
        um_fetch_user(um_get_requested_user());
        $content = um_convert_tags(um_get_option('profile_desc'));
        $user_id = um_user('ID');
        $url = um_user_profile_url();
        if (um_profile('profile_photo')) {
            $avatar = um_user_uploads_uri() . um_profile('profile_photo');
        } else {
            $avatar = um_get_default_avatar_uri();
        }
        um_reset_user();
        ?>

			<meta name="description" content="<?php 
        echo $content;
        ?>
">

			<meta property="og:title" content="<?php 
        echo um_get_display_name($user_id);
        ?>
" />
			<meta property="og:type" content="article" />
			<meta property="og:image" content="<?php 
        echo $avatar;
        ?>
" />
			<meta property="og:url" content="<?php 
        echo $url;
        ?>
" />
			<meta property="og:description" content="<?php 
        echo $content;
        ?>
" />

		<?php 
    }
}
function um_profile_field_filter_hook__image($value, $data)
{
    $uri = um_user_uploads_uri() . $value;
    $title = isset($data['title']) ? $data['title'] : __('Untitled photo');
    // if value is an image tag
    if (preg_match('/\\<img.*src=\\"([^"]+).*/', $value, $matches)) {
        $uri = $matches[1];
        $value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="' . $uri . '"><img src="' . $uri . '" alt="' . $title . '" title="' . $title . '" class="" /></a></div>';
    } else {
        if (file_exists(um_user_uploads_dir() . $value)) {
            $value = '<div class="um-photo"><a href="#" class="um-photo-modal" data-src="' . $uri . '"><img src="' . $uri . '" alt="' . $title . '" title="' . $title . '" class="" /></a></div>';
        } else {
            $value = '';
        }
    }
    return $value;
}
function um_get_avatar_uri($image, $attrs)
{
    global $ultimatemember;
    $uri = false;
    $find = false;
    $ext = '.' . pathinfo($image, PATHINFO_EXTENSION);
    $cache_time = apply_filters('um_filter_avatar_cache_time', current_time('timestamp'), um_user('ID'));
    if (file_exists($ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo-' . $attrs . $ext)) {
        $uri = um_user_uploads_uri() . 'profile_photo-' . $attrs . $ext . '?' . $cache_time;
    } else {
        $sizes = um_get_option('photo_thumb_sizes');
        if (is_array($sizes)) {
            $find = um_closest_num($sizes, $attrs);
        }
        if (file_exists($ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo-' . $find . $ext)) {
            $uri = um_user_uploads_uri() . 'profile_photo-' . $find . $ext . '?' . $cache_time;
        } else {
            if (file_exists($ultimatemember->files->upload_basedir . um_user('ID') . '/profile_photo' . $ext)) {
                $uri = um_user_uploads_uri() . 'profile_photo' . $ext . '?' . $cache_time;
            }
        }
        if ($attrs == 'original') {
            $uri = um_user_uploads_uri() . 'profile_photo' . $ext . '?' . $cache_time;
        }
    }
    return $uri;
}