global $user

Public

From the 'users' table:

uid - User ID
name - User name
pass - Encrypted password
mail - User current email address
theme - Name of the theme shown for this user (no longer changeable in core but can be in contrib)
signature - Signature as set in the user account settings
signature_format - Text format to apply to signature
created - Unix timstamp for when the account was created
access - Unix timstamp of the last time the user accessed the site
login - Unix timstamp of the last successful login by this user
status - 1 if the user is active, 0 if blocked
timezone - User's timezone as a PHP compatible timezone string ( date_default_timezone_set() )
language - User's language code
picture - User picture / avatar
init - Contains the email address the user provided during initial registration
data - Data stored in the users table by contrib modules (second argument of user_save())

From the 'sessions' table:

sid - Session ID for HTTP sessions
ssid - Session ID for HTTPS sessions
hostname - User's IP address
timestamp - A timestamp of last user access
cache - A timestamp used in cache.inc to check freshness of cached data
session - Variables stored in the session through $_SESSION

From the 'user_roles' table:
roles - Array of roles assigned to the user

</> CopyGet raw version
php
  1. mymodule_menu(){
  2. $items=array();
  3. $items['custmomenu'] => array(
  4. 'title' => 'yourtitle',
  5. 'page callback' => 'yourcallback function' ,
  6. 'access callback' = > 'user_is_logged_in',
  7. );
  8. }

function user_is_logged_in
to detect if a user just logged in:

</> CopyGet raw version
php
  1. function user_is_logged_in() {
  2. return (bool) $GLOBALS ['user']->uid;
  3. }
  4.  
  5. if (property_exists($GLOBALS['user'],'login') && $GLOBALS['user']->login == $GLOBALS['user']->timestamp) {
  6. //Do stuff
  7. }

nah

</> CopyGet raw version
php
  1. if ($user->uid == 0) {
  2. //user is not logged in
  3. }
  4.  
  5. $newuser = new stdClass();
  6. $newuser->name = 'johnny';
  7.  
  8. user_save($newuser);

Much more compact. However, there's a todo on user_save() saying they're going to change the behavior, so you might do something like this:

</> CopyGet raw version
php
  1. $newuser = user_save(drupal_anonymous_user(), array('name'=>'johnny'));
  2.  
  3.  
  4. $newuser = drupal_anonymous_user();
  5. $newuser->name = 'johnny';
  6. $newuser = user_save($newuser);