When hook_user_format_name_alter() is implemented, the value that is assigned to the $name variable in this hook makes its way into $form['author']['name']['#default_value'] and $form['author']['name']['#value'] of the comment form. The comment author is then the anonymous user and not the user that saved the comment.

CommentFileSizeAuthor
#2 2566245-2.patch1.73 KBmorenstrat

Comments

dunix created an issue. See original summary.

morenstrat’s picture

Status: Active » Needs review
StatusFileSize
new1.73 KB

This patch fixed the issue for me.

morenstrat’s picture

There are other places where hook_user_format_name_alter() interferes. The user edit form is one example where the real user name gets replaced by the formatted user name. Maybe the AccountInterface should get an additional method getRawUsername?

znerol’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#2571909: CommentForm selects using the user formatted name

Closing this as a duplicate of #2571909: CommentForm selects using the user formatted name since the patch in the other issue resolves the problem in the correct way.