drupal 8 custom create new user view code example
Example: drupal create user
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$user = \Drupal\user\Entity\User::create();
$user->setPassword('test');
$user->enforceIsNew();
$user->setEmail('[email protected]');
$user->setUsername('test');
$user->set("init", 'email');
$user->set("langcode", $language);
$user->set("preferred_langcode", $language);
$user->set("preferred_admin_langcode", $language);
$user->activate();
$user->save();