You are here

function drupal_anonymous_user in Drupal 7

Same name and namespace in other branches
  1. 5 includes/bootstrap.inc \drupal_anonymous_user()
  2. 6 includes/bootstrap.inc \drupal_anonymous_user()

Generates a default anonymous $user object.

Return value

Object - the user object.

12 calls to 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.
UserPasswordResetTestCase::testResetImpersonation in modules/user/user.test
Make sure that users cannot forge password reset URLs of other users.

... See full list

File

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

Code

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