You are here

function user_registrationpassword_install in User registration password 8

Same name and namespace in other branches
  1. 6 user_registrationpassword.install \user_registrationpassword_install()
  2. 7 user_registrationpassword.install \user_registrationpassword_install()

Implements hook_install().

File

./user_registrationpassword.install, line 14
Install file.

Code

function user_registrationpassword_install() {

  // Set the correct default configuration settings so the module needs no more
  // configuration.
  //
  // Load configurations.
  $user_config = \Drupal::configFactory()
    ->getEditable('user.settings');
  $user_mail_config = \Drupal::configFactory()
    ->getEditable('user.mail');
  $mail_original_config = \Drupal::configFactory()
    ->getEditable('user_registrationpassword.mail_original');
  $user_config
    ->set('register', UserInterface::REGISTER_VISITORS)
    ->set('verify_mail', 0)
    ->set('notify.register_pending_approval', 0)
    ->set('notify.register_no_approval_required', 0)
    ->save();

  // Save the original activation email template to a variable, so we can revive
  // them when we uninstall the module.
  $mail_original_config
    ->set('status_activated.subject', $user_mail_config
    ->get('status_activated.subject'))
    ->set('status_activated.body', $user_mail_config
    ->get('status_activated.body'))
    ->save();

  // Set basic email template variable for the account activation email so it
  // makes sense.
  $user_mail_config
    ->set('status_activated.subject', 'Account details for [user:display-name] at [site:name]')
    ->set('status_activated.body', '[user:display-name],

Your account at [site:name] has been activated.

You will be able to log in to [site:login-url] in the future using:

username: [user:name]
password: your password.

-- [site:name] team')
    ->save();
}