Not sure if this is a bug or intended functionality, but when displaying a comment from an authenticated user the comment name value in the comment object is always the user name.
My implementation overwrites the username value when a comment is submitted, giving the user the option to change the name they use when submitting a comment. This value gets stored in the comment table (in the name field), but when the comment is viewed on the front end the name is always the username of the user who submitted it, even though in the admin it shows the value from the comment table.

I have tracked this down to the following code in the comment module:

/**
* Controller class for comments.
*
* This extends the DrupalDefaultEntityController class, adding required
* special handling for comment objects.
*/
class CommentController extends DrupalDefaultEntityController {

protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
$query = parent::buildQuery($ids, $conditions, $revision_id);
// Specify additional fields from the user and node tables.
$query->innerJoin('node', 'n', 'base.nid = n.nid');
$query->addField('n', 'type', 'node_type');
$query->innerJoin('users', 'u', 'base.uid = u.uid');
$query->addField('u', 'name', 'registered_name');
$query->fields('u', array('uid', 'signature', 'signature_format', 'picture'));
return $query;
}

protected function attachLoad(&$comments, $revision_id = FALSE) {
// Setup standard comment properties.
foreach ($comments as $key => $comment) {
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$comment->new = node_mark($comment->nid, $comment->changed);
$comment->node_type = 'comment_node_' . $comment->node_type;
$comments[$key] = $comment;
}
parent::attachLoad($comments, $revision_id);
}
}

Basically the $comment->name value will always be set to $comment->registered_name if the comment is submitted by an authenticated user, and the $comment->registered_name value is the name field from the users table. This means that an authenticated user does not have the ability to display an different name to their username when they post a comment.

Currently i get around this by using hook_comment_view to set the correct value from $comment->name, but i am not sure if this is an issue that should be resolved in the core comment module.

Comments

Version: 7.21 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.