By default, Moodle does not display the user's username as on of the columns in the "Browse list of users" list. See the image below. This is for privacy reasons.
However, there can be times when it is needful for the Moodle administrator to have the usernames appear. For example, the administrator could make it mandatory for all usernames to be the same as the user's corporate or institute E-mail address. And the administrator would like to verify that this rule has been adhered to.
I was surfing for a way to do this for my Moodle 2.7 production site, when I stumbled upon this post in Moodle.org. At the end of this post, you will be able to add the username as an extra column in the Browse list of users list.
Here's how you do it.
You will need to edit the file /admin/user.php. Insert 'username', inside the code at line 162.
So that the code
array('city', 'country', 'lastaccess'));
array('username','city', 'country', 'lastaccess'));
Next, insert the code
$table->head = $username;
$table->colclasses = 'leftalign';
at around line 263, just before the code
$table->head = $city;
The result? This time the Username appears next to the City/Town column. Now you know.
Almost nothing is impossible with Moodle.
Frankie Kam, Malaysia
Postscript. 23rd April 2015. Thanks to Tim Hunt for pointing out a simpler way. I edited my config.php file and added this line: $CFG->showuseridentity = 'username,email';
I also edited the original, vanilla user.php file by commenting this line
//$table->head = $fullnamedisplay;
and adding this line of code:
$table->head = "Name";
like so (at line 269):
in order to achieve this effect:
Ah, satisfaction at last. Thank you, Tim!
Cheers from the Land of Nasi Lemak and Assam Laksa,