function global_filter_user_profile_field in Views Global Filter 6
Same name and namespace in other branches
- 8 global_filter.module \global_filter_user_profile_field()
- 7 global_filter.module \global_filter_user_profile_field()
Retrieve the supplied field value from the user profile.
File
- ./
global_filter.module, line 307 - global_filter.module
Code
function global_filter_user_profile_field($field_name) {
global $user;
if ($field = field_info_field($field_name)) {
$account = user_load($user->uid);
$language = empty($account->language) ? LANGUAGE_NONE : $account->language;
$key = $field['type'] == 'taxonomy_term_reference' ? 'tid' : 'value';
if (isset($account->{$field_name}[$language][0][$key])) {
return $account->{$field_name}[$language][0][$key];
}
}
return NULL;
}