Using Usernames for assigning roles and enrolling for courses

Using Usernames for assigning roles and enrolling for courses

by Azhar Ghani -
Number of replies: 1

hi,

I think this is a custom requirement for using username more frequently (and with more dependability) for assigning roles and enrolling for courses, instead of Full Name and Email.

Open to house.. to comment and solutions??

Average of ratings: -
In reply to Azhar Ghani

Re: Using Usernames for assigning roles and enrolling for courses

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

Azhar - Generally it is considered a slight security risk to unnecessarily exposure a username. Once a cracker has the username then they only need to guess the password. For that reason, in Moodle core you will not see usernames used in many places as that is a deliberate decision.  If you want to use the username rather than the user's actual name, you could look at the fullname function in /lib/moodlelib.php and see what you want to do. I might be tempted to add an optional parameter (for example, username) to the fullname function. When username parameter is true, then print the username instead of the user's full name. Otherwise, behave normally. That way you could do a grep of the code and see when fullname is being used and simply add the additional parameter to fullname function and get what you want. In any case, that is just one idea off the top of my head. As I said at the beginning, it is not really recommended. Peace - Anthony