You are here

function login_destination_entity_presave in Login Destination 8.2

Same name and namespace in other branches
  1. 8 login_destination.module \login_destination_entity_presave()

Implements hook_entity_presave().

File

./login_destination.module, line 146
Control where users are directed to, once they login, register or logout.

Code

function login_destination_entity_presave(EntityInterface $entity) {

  // Verify that entity is a user entity, and this is new entity.
  if (!$entity instanceof UserInterface || !$entity
    ->isNew()) {
    return;
  }

  // Save parameter to user entity, which will allow us understand that user
  // is just created. Do not need to save parameter, when needs verification
  // by administrator.
  $needs_verification = \Drupal::config('user.settings')
    ->get('verify_mail');
  if ($needs_verification || !$entity
    ->isActive()) {
    return;
  }
  $entity->user_is_new = TRUE;
}