5 * Install, update and uninstall functions for the user module.
9 * Implements hook_schema().
11 function user_schema() {
12 $schema['users_data'] = [
13 'description' => 'Stores module data as key/value pairs per user.',
16 'description' => 'Primary key: {users}.uid for user.',
23 'description' => 'The name of the module declaring the variable.',
24 'type' => 'varchar_ascii',
25 'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
30 'description' => 'The identifier of the data.',
31 'type' => 'varchar_ascii',
37 'description' => 'The value.',
43 'description' => 'Whether value is serialized.',
50 'primary key' => ['uid', 'module', 'name'],
52 'module' => ['module'],
56 'uid' => ['users' => 'uid'],
64 * Implements hook_install().
66 function user_install() {
67 $storage = \Drupal::entityManager()->getStorage('user');
68 // Insert a row for the anonymous user.
77 // We need some placeholders here as name and mail are unique.
78 // This will be changed by the settings form in the installer.
82 'name' => 'placeholder-for-uid-1',
83 'mail' => 'placeholder-for-uid-1',
90 * Fix invalid token in the status_blocked email body.
92 function user_update_8100() {
93 $config_factory = \Drupal::configFactory();
94 $config = $config_factory->getEditable('user.mail');
95 $mail = $config->get('status_blocked');
96 if (strpos($mail['body'], '[site:account-name]') !== FALSE) {
97 $mail['body'] = str_replace('[site:account-name]', '[site:name]', $mail['body']);
98 $config->set('status_blocked', $mail)->save(TRUE);