function drupal_anonymous_user
Generates a default anonymous $user object.
Return value
Object - the user object.
14 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.
File
-
includes/
bootstrap.inc, line 2513
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.