Is there something that provides userdata array for other users already in place? I haven't found it if it is, so I made me a class to help me out fetch this information.
When modding the system to do my bidding for this project I'm working on, I need usernames, user level, last login date, stuff like that, from given user based on ID because I am showing a list.... and I am doing various stages and I have to write this stuff repeatedly, so when I saw I'd have to repeatedly query the db to get this data I knew it was time to make something up....
Find the attached file, its a class you can put in the /includes/classes folder
I named it UserDataHelper, but y'all can rename it to whatever you like.
I also added the methods I needed at the moment, but you can, of course, expand it to fetch whatever user information you need. For instance, cross-table data, like comments count, download file uploaded count, forum post count, etc.
You can also collaborate in making it better by going onto the github gist
here or posting your improved version on this thread.
P.S. As a shortcut, when instantiating the class, you must provide a user id there, so it pre-fetches user data onto an array var in the class, then you can call getter methods that lookup array keys from that array. To see what kind of data is pulled, look into the fetchUserData method, it has the query. I am purposefully avoiding to SELECT * as a security measure, because I don't want to pull hashes or algo identification of any kind, so I am naming the columns I want explicitly.
Usage would be like:
$user_object = new UserDataHelper($id);
$username = $user_object->getUserName();
Note to self (lol): The getter methods could be made static so it is easier to call them up once the class has been instantiated.