There was an annoying issue with the old version of the user creation screen. The system automatically creates a username when you enter the first name/last name fields. It always follows the ‘lastnamefirstinitial’ format. However, usernames must be unique in the system (at least, within that site’s record), so if you tried to save an account with an identical username, you’d get an errror.
What’s worse, there would be no warning- you’d just get a full refresh of the form, lose all your entered data, and have to start again.
So I set up an ajax function to check the username against those in the db for that site’s record. If it finds a match, it will add another letter from the first name to the username (lastname + first 2 initials). That way, we can keep a very similar format and eliminate some admin frustration.
I’m not sure how most devs do it, but my main method of testing for this was logging everything to the console. The data I passed to my php page, the response it gave me, etc. When I had it matched up right, I just pulled the log calls and it was good to go. I’m betting there’s a better way to do this, but it works for now.