function userpro_show_field($key, $array, $i, $args, $user_id = null) { global $userpro; extract($array); extract($args); $res = null; /** include & exclude done by custom shortcode params start here **/ if (isset($args['exclude_fields']) && $args['exclude_fields'] != '') { if (in_array($key, explode(',', $args['exclude_fields']))) { $res = ''; return false; } } if (isset($args['exclude_fields_by_name']) && $args['exclude_fields_by_name'] != '') { if (in_array($array['label'], explode(',', $args['exclude_fields_by_name']))) { $res = ''; return false; } } if (isset($args['exclude_fields_by_type']) && $args['exclude_fields_by_type'] != '') { if (isset($array['type']) && in_array($array['type'], explode(',', $args['exclude_fields_by_type']))) { $res = ''; return false; } } if (isset($args['include_fields']) && $args['include_fields'] != '') { if (!in_array($key, explode(',', $args['include_fields']))) { $res = ''; return false; } } if (isset($args['include_fields_by_name']) && $args['include_fields_by_name'] != '') { if (!in_array($array['label'], explode(',', $args['include_fields_by_name']))) { $res = ''; return false; } } if (isset($args['include_fields_by_type']) && $args['include_fields_by_type'] != '') { if (isset($array['type']) && !in_array($array['type'], explode(',', $args['include_fields_by_type'])) || !isset($array['type'])) { $res = ''; return false; } } /** end here thanks please do not edit here unless you know what you do **/ if ($user_id) { $value = userpro_profile_data($key, $user_id); if (isset($array['type']) && $key != 'role' && in_array($array['type'], array('select', 'multiselect', 'checkbox', 'checkbox-full', 'radio', 'radio-full'))) { $value = userpro_profile_data_nicename($key, userpro_profile_data($key, $user_id)); } if (isset($array['html']) && $array['html'] == 0) { $value = userpro_profile_nohtml($value); } if (isset($array['type']) && $array['type'] == 'picture') { if ($key == 'profilepicture') { $value = get_avatar($user_id, 64); } else { $crop = userpro_profile_data($key, $user_id); if ($crop) { if (isset($array['width'])) { $width = $array['width']; $height = $array['height']; } else { $width = ''; $height = ''; } $value = '<img src="' . $crop . '" width="' . $width . '" height="' . $height . '" alt="" class="modified" />'; } } } if (isset($array['type']) && $array['type'] == 'file') { $file = userpro_profile_data($key, $user_id); if ($file) { $value = '<div class="userpro-file-input"><a href="' . $file . '" ' . userpro_file_type_icon($file) . '>' . basename($file) . '</a></div>'; } } } /* display a section */ if ($allow_sections && isset($array['heading'])) { $res .= "<div class='userpro-section userpro-column userpro-collapsible-" . $array['collapsible'] . " userpro-collapsed-" . $array['collapsed'] . "'>" . $array['heading'] . "</div>"; } /* display a field */ if (!$user_id) { $user_id = 0; } if (isset($array['type']) && userpro_field_by_role($key, $user_id) && !empty($value) && userpro_field_is_viewable($key, $user_id, $args) && !in_array($key, $userpro->fields_to_hide_from_view()) && $array['type'] != 'mailchimp' && $array['type'] != 'followers') { $res .= "<div class='userpro-field userpro-field-" . $key . " " . userpro_private_field_class($array) . " userpro-field-{$template}' data-key='{$key}'>"; if ($array['label'] && $array['type'] != 'passwordstrength') { if ($args['field_icons'] == 1) { $res .= "<div class='userpro-label view iconed'>"; } else { $res .= "<div class='userpro-label view'>"; } $res .= "<label for='{$key}-{$i}'>" . $array['label'] . "</label>"; if ($args['field_icons'] == 1 && $userpro->field_icon($key)) { $res .= '<span class="userpro-field-icon"><i class="userpro-icon-' . $userpro->field_icon($key) . '"></i></span>'; } $res .= "</div>"; } $res .= "<div class='userpro-input'>"; //*** /* Before custom field is displayed! */ /**/ $value = apply_filters('userpro_before_value_is_displayed', $value, $key, $array, $user_id); /* SHOW VALUE */ $countrylist = get_option('userpro_fields'); $country = $countrylist['billing_country']['options']; if ($key == 'role') { $res .= userpro_user_role($value); } elseif ($key == 'billing_country') { foreach ($country as $country_code => $country_name) { if ($country_name == $value) { $res .= $value; } if ($country_code == $value) { $value = $country_name; $res .= $value; } } } elseif ($key == 'shipping_country') { foreach ($country as $country_code => $country_name) { if ($country_name == $value) { $res .= $value; } if ($country_code == $value) { $value = $country_name; $res .= $value; } } } else { $res .= $value; } /* hidden field notice */ if (userpro_field_is_viewable($key, $user_id, $args) && (userpro_profile_data('hide_' . $key, $user_id) || userpro_field_default_hidden($key, $template, $args[$template . '_group']))) { $res .= '<div class="userpro-help">' . sprintf(__('(Your %s will not be visible to public)', 'userpro'), strtolower($array['label'])) . '</div>'; } $res .= "<div class='userpro-clear'></div>"; $res .= "</div>"; $res .= "</div><div class='userpro-clear'></div>"; } return $res; }
function userpro_field_is_viewable($key, $user_id, $args) { if (current_user_can('manage_options')) { return true; } if ($user_id == get_current_user_id()) { return true; } if (isset($args[$args['template'] . '_group']) && userpro_field_default_hidden($key, $args['template'], $args[$args['template'] . '_group'])) { return false; } $test = get_user_meta($user_id, 'hide_' . $key, true); if ($test == 1 && $user_id != get_current_user_id()) { return false; } return true; }