Register a user without email verification should still send an email

Created on 24 September 2018, over 5 years ago
Updated 11 May 2023, about 1 year ago

I believe this being a follow up to #2291055: REST resources for anonymous users: register .

I am creating an user with the rest resource, configured not to verify email address, and the register_no_approval_required is not sent.

However, registering the user with the same settings through the drupal UI as an anonymous user does send the notification.

One would expect the same behavior:

./core/modules/user/src/RegisterForm.php

    // No email verification required; log in user immediately.
    elseif (!$admin && !\Drupal::config('user.settings')->get('verify_mail') && $account->isActive()) {
      _user_mail_notify('register_no_approval_required', $account);
      user_login_finalize($account);
      drupal_set_message($this->t('Registration successful. You are now logged in.'));
      $form_state->setRedirect('<front>');
    }

./core/modules/user/src/Plugin/rest/resource/UserRegistrationResource.php:

  protected function sendEmailNotifications(UserInterface $account) {
    $approval_settings = $this->userSettings->get('register');
    // No e-mail verification is required. Activating the user.
    if ($approval_settings == USER_REGISTER_VISITORS) {
      if ($this->userSettings->get('verify_mail')) {
        // No administrator approval required.
        _user_mail_notify('register_no_approval_required', $account);
      }
    }
    // Administrator approval required.
    elseif ($approval_settings == USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) {
      _user_mail_notify('register_pending_approval', $account);
    }
  }

🐛 Bug report
Status

Needs work

Version

10.1

Component
User module 

Last updated 3 days ago

Created by

🇦🇷Argentina hanoii 🇦🇷UTC-3

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024