function um_user($data, $attrs = null) { global $ultimatemember; switch ($data) { default: $value = um_profile($data); if ($ultimatemember->validation->is_serialized($value)) { $value = unserialize($value); } if ($data == 'role') { return strtolower($value); } return $value; break; case 'full_name': if (um_user('first_name') && um_user('last_name')) { $full_name = um_user('first_name') . ' ' . um_user('last_name'); } else { $full_name = um_user('display_name'); } $full_name = $ultimatemember->validation->safe_name_in_url($full_name); // update full_name changed if (um_profile($data) !== $full_name) { update_user_meta(um_user('ID'), 'full_name', $full_name); } return $full_name; break; case 'display_name': $op = um_get_option('display_name'); $name = ''; if ($op == 'default') { $name = um_profile('display_name'); } if ($op == 'nickname') { $name = um_profile('nickname'); } if ($op == 'full_name') { if (um_user('first_name') && um_user('last_name')) { $name = um_user('first_name') . ' ' . um_user('last_name'); } else { $name = um_profile($data); } if (!$name) { $name = um_user('user_login'); } } if ($op == 'sur_name') { if (um_user('first_name') && um_user('last_name')) { $name = um_user('last_name') . ' ' . um_user('first_name'); } else { $name = um_profile($data); } } if ($op == 'first_name') { if (um_user('first_name')) { $name = um_user('first_name'); } else { $name = um_profile($data); } } if ($op == 'username') { $name = um_user('user_login'); } if ($op == 'initial_name') { if (um_user('first_name') && um_user('last_name')) { $initial = um_user('last_name'); $name = um_user('first_name') . ' ' . $initial[0]; } else { $name = um_profile($data); } } if ($op == 'initial_name_f') { if (um_user('first_name') && um_user('last_name')) { $initial = um_user('first_name'); $name = $initial[0] . ' ' . um_user('last_name'); } else { $name = um_profile($data); } } if ($op == 'field' && um_get_option('display_name_field') != '') { $fields = array_filter(preg_split('/[,\\s]+/', um_get_option('display_name_field'))); $name = ''; foreach ($fields as $field) { $name .= um_profile($field) . ' '; } } return apply_filters('um_user_display_name_filter', $name, um_user('ID'), $attrs == 'html' ? 1 : 0); break; case 'role_select': case 'role_radio': return $ultimatemember->user->get_role_name(um_user('role')); break; case 'submitted': $array = um_profile($data); if (empty($array)) { return ''; } $array = unserialize($array); return $array; break; case 'password_reset_link': return $ultimatemember->password->reset_url(); break; case 'account_activation_link': return $ultimatemember->permalinks->activate_url(); break; case 'profile_photo': $has_profile_photo = false; if (um_profile('profile_photo')) { $avatar_uri = um_get_avatar_uri(um_profile('profile_photo'), $attrs); $has_profile_photo = true; } else { $avatar_uri = um_get_default_avatar_uri(um_user('ID')); } $avatar_uri = apply_filters('um_user_avatar_url_filter', $avatar_uri, um_user('ID')); if ($avatar_uri) { if (um_get_option('use_gravatars') && !um_user('synced_profile_photo') && !$has_profile_photo) { $avatar_uri = um_get_domain_protocol() . 'gravatar.com/avatar/' . um_user('synced_gravatar_hashed_id'); $avatar_uri = add_query_arg('s', 400, $avatar_uri); if (um_get_option('use_um_gravatar_default_image')) { $avatar_uri = add_query_arg('d', um_get_default_avatar_uri(), $avatar_uri); } } } return '<img src="' . $avatar_uri . '" class="func-um_user gravatar avatar avatar-' . $attrs . ' um-avatar" width="' . $attrs . '" height="' . $attrs . '" alt="" />'; if (!$avatar_uri) { return ''; } break; case 'cover_photo': if (um_profile('cover_photo')) { $cover_uri = um_get_cover_uri(um_profile('cover_photo'), $attrs); } else { $cover_uri = um_get_default_cover_uri(); } if ($cover_uri) { return '<img src="' . $cover_uri . '" alt="" />'; } if (!$cover_uri) { return ''; } break; } }
function um_user($data, $attrs = null) { global $ultimatemember; switch ($data) { default: $value = um_profile($data); if ($ultimatemember->validation->is_serialized($value)) { $value = unserialize($value); } return $value; break; case 'full_name': if (!um_profile($data)) { if (um_user('first_name') && um_user('last_name')) { $full_name = um_user('first_name') . '.' . um_user('last_name'); } else { $full_name = um_user('display_name'); } $full_name = $ultimatemember->validation->safe_name_in_url($full_name); update_user_meta(um_user('ID'), 'full_name', $full_name); return $full_name; } else { return um_profile($data); } break; case 'display_name': $op = um_get_option('display_name'); if ($op == 'full_name') { if (um_user('first_name') && um_user('last_name')) { $name = um_user('first_name') . ' ' . um_user('last_name'); } else { $name = um_profile($data); } } if ($op == 'sur_name') { if (um_user('first_name') && um_user('last_name')) { $name = um_user('last_name') . ', ' . um_user('first_name'); } else { $name = um_profile($data); } } if ($op == 'first_name') { if (um_user('first_name')) { $name = um_user('first_name'); } else { $name = um_profile($data); } } if ($op == 'username') { $name = um_user('user_login'); } if ($op == 'initial_name') { if (um_user('first_name') && um_user('last_name')) { $initial = um_user('last_name'); $name = um_user('first_name') . ' ' . $initial[0]; } else { $name = um_profile($data); } } if ($op == 'initial_name_f') { if (um_user('first_name') && um_user('last_name')) { $initial = um_user('first_name'); $name = $initial[0] . ' ' . um_user('last_name'); } else { $name = um_profile($data); } } if ($op == 'public_name') { $name = um_profile($data); } if ($op == 'field' && um_get_option('display_name_field') != '') { $fields = array_filter(preg_split('/[,\\s]+/', um_get_option('display_name_field'))); $name = ''; foreach ($fields as $field) { $name .= um_profile($field) . ' '; } } return apply_filters('um_user_display_name_filter', $name, um_user('ID'), $attrs == 'html' ? 1 : 0); break; case 'role_select': case 'role_radio': return $ultimatemember->user->get_role_name(um_user('role')); break; case 'submitted': $array = um_profile($data); if (empty($array)) { return ''; } $array = unserialize($array); return $array; break; case 'password_reset_link': return $ultimatemember->password->reset_url(); break; case 'account_activation_link': return $ultimatemember->permalinks->activate_url(); break; case 'profile_photo': if (um_profile('profile_photo')) { $avatar_uri = um_get_avatar_uri(um_profile('profile_photo'), $attrs); } else { $avatar_uri = um_get_default_avatar_uri(); } $avatar_uri = apply_filters('um_user_avatar_url_filter', $avatar_uri, um_user('ID')); if ($avatar_uri) { return '<img src="' . $avatar_uri . '" class="gravatar avatar avatar-' . $attrs . ' um-avatar" width="' . $attrs . '" height="' . $attrs . '" alt="" />'; } if (!$avatar_uri) { return ''; } break; case 'cover_photo': if (um_profile('cover_photo')) { $cover_uri = um_get_cover_uri(um_profile('cover_photo'), $attrs); } else { $cover_uri = um_get_default_cover_uri(); } if ($cover_uri) { return '<img src="' . $cover_uri . '" alt="" />'; } if (!$cover_uri) { return ''; } break; } }