function drupal_anonymous_user

Generates a default anonymous $user object.

Return value

Object - the user object.

10 calls to drupal_anonymous_user()
comment_form_node_type_form_alter in drupal/core/modules/comment/comment.module
Implements hook_form_FORM_ID_alter().
drupal_cron_run in drupal/core/includes/common.inc
Executes a cron run when called.
drupal_session_initialize in drupal/core/includes/session.inc
Initializes the session handler, starting a session if needed.
UserEntityCallbacksTest::setUp in drupal/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php
Sets up a Drupal site for running functional and integration tests.
user_attach_accounts in drupal/core/modules/user/user.module
Populates $entity->account for each prepared entity.

... See full list

File

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

Code

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