function user_install

Same name in other branches
  1. 7.x modules/user/user.install \user_install()
  2. 9 core/modules/user/user.install \user_install()
  3. 10 core/modules/user/user.install \user_install()
  4. 11.x core/modules/user/user.install \user_install()

Implements hook_install().

3 calls to user_install()
MigrateUserAdminPassTest::setUp in core/modules/user/tests/src/Kernel/Migrate/MigrateUserAdminPassTest.php
MigrateUserTest::setUp in core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php
UserInstallTest::setUp in core/modules/user/tests/src/Kernel/UserInstallTest.php

File

core/modules/user/user.install, line 71

Code

function user_install() {
    $storage = \Drupal::entityTypeManager()->getStorage('user');
    // Insert a row for the anonymous user.
    $storage->create([
        'uid' => 0,
        'status' => 0,
        'name' => '',
    ])
        ->save();
    // We need some placeholders here as name and mail are unique.
    // This will be changed by the settings form in the installer.
    $storage->create([
        'uid' => 1,
        'name' => 'placeholder-for-uid-1',
        'mail' => 'placeholder-for-uid-1',
        'status' => TRUE,
    ])
        ->save();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.