drupal_anonymous_user

includes/bootstrap.inc, line 945

Versions
5 – 7
drupal_anonymous_user($session = '')

Generates a default anonymous $user object.

Return value

Object - the user object.

▾ 3 functions call drupal_anonymous_user()

comment_form_alter in modules/comment/comment.module
Implementation of hook_form_alter().
sess_read in includes/session.inc
user_logout in modules/user/user.pages.inc
Menu callback; logs the current user out, and redirects to the home page.

Code

<?php
function drupal_anonymous_user($session = '') {
  $user = new stdClass();
  $user->uid = 0;
  $user->hostname = ip_address();
  $user->roles = array();
  $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
  $user->session = $session;
  $user->cache = 0;
  return $user;
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.