I have created a module that overrides the real user name with the string "Anonymous" when a node is displayed. I use hook_node_view() to do this. This works fine.

However, to keep the user truly anonymous, I need to override the display of the user name in other contexts as well, for instance in the views of last post in a forum, or in the forum topic list produced by the core forum module (Drupal 7).

The screenshot below illustrates the problem. It shows a forum post by a user "bob" that is supposed to be Anonymous. As shown, "bob" is not Anonymous in the first two views, only in the last view of the node itself.


What I am looking for is a hook (or something else if there is no explicit hook for this) that let me override the display of the user name in these views produced by the core forum module.


Took me more than two months to figure this one out, but the answer is obvious once you know it.

Yes, there is an explicit hook for this. It is named: hook_username_alter.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.