In Drupal, user_load($uid) function will return an user object. And Drupal has defined a global user object as well (it represents current logged in user).
The user object has following properties:
status -> active/blocked
uid -> user id
mail -> email address
created -> created timestamp
login -> login timestamp
hostname -> ip address
init -> the email address provided at initial registration
roles -> roles assigned to this user
The difference between “mail” property and “init” property is that mail can be changed after registration, but init is the first used email address and cannot be changed. If you want to send email to an user, you need to know his email address ($user->mail).
In Drupal, if you want to let your published node appear in search results, you need to re-index the search first (Administration->Configuration->Search Settings). And the Drupal cron job file (cron.php) will be executed to re-index the site at a specific time on every minute, every hour or every day, etc.
But recently I’m building a project outsourcing site, I need the newly posted project can be searched by other users immediately after it’s published. I searched on Google and Drupal for a while, finally I found this module: Auto-Index.
This module will automatically re-index the nodes every time a new node is created or an existing node is edited. And there is no more configuration needed after installing.
In Drupal the logged in user is stored as a global variable. Following code can access the logged in user ID
And in profile page, you can use $user variable directly