You are here

function simplenews_user_create in Simplenews 8

Same name and namespace in other branches
  1. 8.2 simplenews.module \simplenews_user_create()
  2. 3.x simplenews.module \simplenews_user_create()

Implements hook_ENTITY_TYPE_create().

File

./simplenews.module, line 417
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_user_create(UserInterface $account) {

  // Copy values for shared fields from existing subscriber.
  $mail = $account
    ->getEmail();
  $sync = \Drupal::config('simplenews.settings')
    ->get('subscriber.sync_fields');
  if ($sync && $mail && ($subscriber = simplenews_subscriber_load_by_mail($mail))) {
    foreach ($subscriber
      ->getUserSharedFields($account) as $field_name) {
      $account
        ->set($field_name, $subscriber
        ->get($field_name)
        ->getValue());
    }
  }
}