Community Documentation

drupal_anonymous_user

5 bootstrap.inc drupal_anonymous_user($session = '')
6 bootstrap.inc drupal_anonymous_user($session = '')
7 bootstrap.inc drupal_anonymous_user()
8 bootstrap.inc drupal_anonymous_user()

Generates a default anonymous $user object.

Return value

Object - the user object.

▾ 10 functions call drupal_anonymous_user()

comment_form_node_type_form_alter in modules/comment/comment.module
Implements hook_form_FORM_ID_alter().
DrupalWebTestCase::drupalCreateUser in modules/simpletest/drupal_web_test_case.php
Create a user with a given set of permissions.
drupal_cron_run in includes/common.inc
Executes a cron run when called.
drupal_session_initialize in includes/session.inc
Initializes the session handler, starting a session if needed.
UserSaveTestCase::testUserImport in modules/user/user.test
Test creating a user with arbitrary uid.
user_external_login_register in modules/user/user.module
Helper function for authentication modules. Either logs in or registers the current user, based on username. Either way, the global $user object is populated and login tasks are performed.
user_register_form in modules/user/user.module
Form builder; the user registration form.
_drupal_bootstrap_page_cache in includes/bootstrap.inc
Attempts to serve a page from the cache.
_drupal_session_destroy in includes/session.inc
Session handler assigned by session_set_save_handler().
_drupal_session_read in includes/session.inc
Reads an entire session from the database (internal use only).

File

includes/bootstrap.inc, line 2068
Functions that need to be loaded on every Drupal request.

Code

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

Comments

Note this is not a complete

Note this is not a complete user object that gets run through hook_entity_load() and hook_user_load(). It doesn't have typical keys like 'name', 'mail', etc that normal user account objects do.

Login or register to post comments