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);
}
}