Display Username on sidebar Menu

Hello everyone,I had already noticed that, the Usename is displayed in the top left of the sidebar, my question is, can it be changed to another field in my Users table?For example I have a field that is the full name, I would like to show that, instead of the Username.Thank you.

If you yse v2024, you may use the LoginStatusEvent, see Event Listeners, e.g.

AddListener(LoginStatusEvent::NAME, function(LoginStatusEvent $event) {
    // Log("LoginStatus", $event->getArguments()); // Log the content for viewing in log file
    $event["currentUserName"] = CurrentUserInfo("MyFullNameField"); // Replace "MyFullNameField" by your actual field name
});

Thank you, it works perfectly!

Hello - I am trying to make this work but can’t figure out where to put this code? Please explain where I put this. Thanks!

As mentioned in the Event Listeners link above, you may simply put your code in Global Code server event. It is located under Server Events → Global → All Pages.

what if in version 2022?

Already answered in another similar topic: Display Username on sidebar Menu (v2022).

Hi, i have a new problem with this, I enable “Swtich user” on Security settings, when i switch an user, the option to switch back below the username, it doesn’t appers.

How can I add the option to swtich back, but keep the setting “fullname” that you gave me?

You may refer to logic of SetupLoginStatus global function in the generated src/phpfn.php file, how to handle the “exit impersonation template”.

Thank you very much, I saw it and fix the problem