Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By vasan.85 on
hi,
i need the mysql query for identifying the current logged user.is any one knows plz share with me.
thanks
Comments
No query required. To get the
No query required. To get the current user's object, use the following snippet.
That simple :)
----------------------
Nick Santamaria
current user
hi
Actually i need to display the current user friends in map.regarding to that i need mysql query to get the current logged user id.how i do that.will you help to that
thanks
User id (uid) is part of
User id (uid) is part of $user, example
Here is a "hack" I wrote that
Here is a "hack" I wrote that does that and also creates a variable with the access level of the user:
If you just want to get the user ID your code would look like this:
Note:
There might be typos in the commented part. The original code block is clear for sure though.
The code should be using the
The code should be using the db abstraction layer, db_query() and db_fetch_array() in this case. The code should not directly connect to the Drupal database, core handles that.
You can also do that more directly using the global $user object.
Yah, I'm a noob and I wrote
Yah, I'm a noob and I wrote that for a non-drupal page, hence the manual connect.