Le titre est évocateur. Il faut remplacer YOUR_PROFILE_FIELD par le nom du champ du profile.
Pour que cela fonctionne, il faut bien sûr avoir configuré un champ dans le profile qui contient le nom de l'utilisateur et placer ce code dans le fichier template.php du thème utilisé.
Une autre option est l'utilisation du module Real Name.
Référence: http://drupal.org/node/122303
<?php
function phptemplate_username($object, $link = TRUE) {
if ( !$object->YOUR_PROFILE_FIELD ) {
if ( $object->uid && function_exists('profile_load_profile') ) {
profile_load_profile($object);
}
}
if ( $object->YOUR_PROFILE_FIELD ) {
$name = $object->YOUR_PROFILE_FIELD;
if ( $link && user_access('access user profiles')) {
return l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
}
else {
return check_plain($name);
}
}
// Profile field not set, default to standard behaviour
if ($object->uid && $object->name) {
// Shorten the name when it is too long or it will break many tables.
if (drupal_strlen($object->name) > 20) {
$name = drupal_substr($object->name, 0, 15) .'...';
}
else {
$name = $object->name;
}
if ( $link && user_access('access user profiles')) {
$output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
}
else {
$output = check_plain($name);
}
}
else if ($object->name) {
// Sometimes modules display content composed by people who are
// not registered members of the site (e.g. mailing list or news
// aggregator modules). This clause enables modules to display
// the true author of the content.
if ($object->homepage) {
$output = l($object->name, $object->homepage);
}
}
?>