Looking up user by id verses username?

Forum
Last Post
Threads / Messages

GeneticAlpha

Loving Mysidia!
Member
Joined
May 24, 2020
Messages
287
Points
18
Age
31
Location
Tennessee
Mysidian Dollar
13,377
Does anyone know how I would get the system to search for a user by their ID rather than username?

I'm assuming where it says on the donation file for example, $mysidia->user->username probably needs changed to something like user->uid So would I just change that to uid? I'm wanting my search area and what not and messages to look up people by their id's instead of usernames.
 
Actually the system is able to construct a Member object based on either user ID or username, so that part of functionality is working. All you need to do is to change the database query code, aka the whereclause, to match a user ID rather than a username.
 
I'm sorry, I'm still learning coding lol that database query code, is that something that gets changed in the database or in the file I'm working in?
 
Actually the system is able to construct a Member object based on either user ID or username, so that part of functionality is working. All you need to do is to change the database query code, aka the whereclause, to match a user ID rather than a username.
Could you by chance show me an example of what this looks like?

I'm wanting the search area to be able to search people by ID and the PM system do ID as well instead of usernames.
 
In the classes/class_member.php, the constructor method accepts both numeric value(ie. 1, 2, 3) and string(ie. "Hall of Famer", "Micolai", "Kyttias") value. If you supply a numeric value, it treats the values as user ID. Otherwise it will consider the values as Username:

PHP:
      $whereclause = (is_numeric($userinfo))?"uid ='{$userinfo}'":"username ='{$userinfo}'";

So yeah, if you give a number value to the member object, it will construct from a user ID. If you are referring to the current logged in user, just change $mysidia->user->username to $mysidia->user->uid, and it will use the user ID.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top