Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UserSelection.php

function UserSelection::createNewEntity

Overrides DefaultSelection::createNewEntity

File

core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php, line 189

Class

UserSelection
Provides specific access control for the user entity type.

Namespace

Drupal\user\Plugin\EntityReferenceSelection

Code

public function createNewEntity($entity_type_id, $bundle, $label, $uid) {
    $user = parent::createNewEntity($entity_type_id, $bundle, $label, $uid);
    // In order to create a referenceable user, it needs to be active.
    if (!$this->currentUser
        ->hasPermission('administer users')) {
        
        /** @var \Drupal\user\UserInterface $user */
        $user->activate();
    }
    return $user;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal