-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunl_user.module
37 lines (33 loc) · 1.02 KB
/
unl_user.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use Drupal\Core\Session\AccountInterface;
use Drupal\user\UserInterface;
/**
* Implements hook_install().
*/
function unl_user_install() {
\Drupal::configFactory()->getEditable('user.settings')
->set('register', UserInterface::REGISTER_ADMINISTRATORS_ONLY)
->save(TRUE);
}
/**
* Implements hook_user_format_name_alter().
*/
function unl_user_user_format_name_alter(&$name, AccountInterface $account) {
$displayName = \Drupal::service('user.data')->get('unl_user', $account->id(), 'displayName');
if ($displayName) {
$name = $displayName;
}
}
/**
* Implements hook_user_login().
*/
function unl_user_user_login(AccountInterface $account) {
// Schedule a user data update for the account.
/** @var \Drupal\Core\Queue\QueueFactory $queue_factory */
$queue_factory = \Drupal::service('queue');
/** @var \Drupal\Core\Queue\QueueInterface $queue */
$queue = $queue_factory->get('cron_unl_user_update_user_data', true);
$item = new \stdClass();
$item->uid = $account->id();
$queue->createItem($item);
}