How to get user_id of another user?

Discussion forum for MOD Writers regarding MOD Development.
Locked
Hikaru Kagi
Registered User
Posts: 6
Joined: Sat Apr 07, 2012 3:17 am

How to get user_id of another user?

Post by Hikaru Kagi »

Simply as the title says, I'd like to know how to get the user_id of another user... like if if I were on the other user's profile, how do I get the user_id from their profile?

User avatar
John P
Registered User
Posts: 1237
Joined: Mon Jan 21, 2008 3:55 pm
Location: Netherlands
Name: John
Contact:

Re: How to get user_id of another user?

Post by John P »

Hover over the user's name, in the link you see the user_id right after u=
Image
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign

Hikaru Kagi
Registered User
Posts: 6
Joined: Sat Apr 07, 2012 3:17 am

Re: How to get user_id of another user?

Post by Hikaru Kagi »

I know that... but how could I apply that in a SQL query?

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51997
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: How to get user_id of another user?

Post by Brf »

You are going to need to explain a bit better.

The user_id of the user whose profile you are viewing is in the u= parameter, which goes into the $user_id variable. Without knowing how you are planning to do this sql query, we cannot help you further.

Hikaru Kagi
Registered User
Posts: 6
Joined: Sat Apr 07, 2012 3:17 am

Re: How to get user_id of another user?

Post by Hikaru Kagi »

I'm making my own visitor comments mod, and basically from what i can tell from the other two comment mods, you need your user_id and the id of the user of the profile that your commenting on, and that's id I'm looking to use. Did that clarify it?

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51997
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: How to get user_id of another user?

Post by Brf »

Brf wrote:The user_id of the user whose profile you are viewing is in the u= parameter, which goes into the $user_id variable.

User avatar
John P
Registered User
Posts: 1237
Joined: Mon Jan 21, 2008 3:55 pm
Location: Netherlands
Name: John
Contact:

Re: How to get user_id of another user?

Post by John P »

Your own user_id is in $user->data['user_id'], the other you ave to find in your comment mod.
Without knowing anything off this mod I can not help you
Image
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign

Drakkim
Registered User
Posts: 176
Joined: Thu Feb 05, 2004 5:48 am
Contact:

Re: How to get user_id of another user?

Post by Drakkim »

Most likely, the user_id will be retrieved with whatever post you are retrieving, be it a PM, a post, or custom data from a mod. In code you will should always have the user_id. What you might have to look for is the username. But more to the point, with either a username or user id, you can get the other. This should be enough to get you started:

Code: Select all

$user_id_ary=array($user_id);
$username_ary=array ();

user_get_id_name ($user_id_ary, $username_ary); //important part!

$username = $username_ary[0];
$user_id = $user_id_ary[0];
Take a look through includes/functions.php... that's where you'll find most of the goodies you'll need to access forum data.

Locked

Return to “[3.0.x] MOD Writers Discussion”