function i18nprofile_profile_alter in Internationalization 5.3
Same name and namespace in other branches
- 5 i18nprofile/i18nprofile.module \i18nprofile_profile_alter()
- 5.2 i18nprofile/i18nprofile.module \i18nprofile_profile_alter()
- 6 i18nprofile/i18nprofile.module \i18nprofile_profile_alter()
Implementation of hook_profile_alter()
File
- i18nprofile/
i18nprofile.module, line 62
Code
function i18nprofile_profile_alter($account, &$fields) {
// var_dump($fields['Personal information']);
// Remove translated categories
$categories = i18nprofile_categories(TRUE);
foreach ($categories as $category => $translation) {
// Translate field titles and names
$i18nfields = i18nprofile_fields($category);
foreach ($i18nfields as $name => $field) {
if (isset($fields[$category][$name])) {
if ($field->title) {
$fields[$category][$name]['title'] = $field->title;
}
if ($field->type == 'selection' && ($options = unserialize($field->options))) {
$value = $fields[$category][$name]['value'];
$fields[$category][$name]['value'] = isset($options[$value]) ? $options[$value] : $value;
}
}
}
if ($translation && $category != $translation && isset($fields[$category])) {
$fields[$translation] = $fields[$category];
unset($fields[$category]);
}
}
}