Це працює для мене:
/**
* Implements hook_field_widget_form_alter().
*/
function MODULE_hook_field_widget_form_alter(&$element, &$form_state, $context) {
// Prevent replace tokens on field admin ui form.
if (!is_null($element['#entity'])) {
// Determine the $user. If entity has uid, try to load. If can't, use the
// global $user.
if (isset($element['#entity']->uid)) {
if (!$user = user_load($element['#entity']->uid)) {
global $user;
}
}
// Build data for token replacement.
$data = array(
$element['#entity_type'] => $element['#entity'],
'user' => $user,
);
// Eg. the body field, the default value is stored in
// $element['#default_value']
if (isset($element['#default_value']) && !is_array($element['#default_value'])) {
$element['#default_value'] = token_replace($element['#default_value'], $data);
}
// Eg. the link field, the default value is stored in
// $element['#default_value']['url']
else if (is_array($element['#default_value'])) {
foreach ($element['#default_value'] as $key => $value) {
if (is_string($value)) {
$element['#default_value'][$key] = token_replace($value, $data);
}
}
}
// Eg. the text field, the default value is stored in
// $element['value']['#default_value']
else if (isset($element['value'])) {
if (isset($element['value']['#default_value']) && !is_array($element['value']['#default_value'])) {
$element['value']['#default_value'] = token_replace($element['value']['#default_value'], $data);
}
}
}
}