protected function createNewUser($arrData)
	{
		$arrData['tstamp'] = time();
		$arrData['login'] = $this->reg_allowLogin;
		$arrData['dateAdded'] = $arrData['tstamp'];

		// Set default groups
		if (!\array_key_exists('groups', $arrData))
		{
			$arrData['groups'] = $this->reg_groups;
		}

		// Disable account
		$arrData['disable'] = 1;

		// Make sure newsletter is an array
		if (isset($arrData['newsletter']) && !\is_array($arrData['newsletter']))
		{
			$arrData['newsletter'] = array($arrData['newsletter']);
		}

		// Create the user
		$objNewUser = new MemberModel();
		$objNewUser->setRow($arrData);
		$objNewUser->save();

		// Store the new ID (see https://github.com/contao/contao/pull/196#discussion_r243555399)
		$arrData['id'] = $objNewUser->id;

		// Send activation e-mail
		if ($this->reg_activate)
		{
			$this->sendActivationMail($arrData);
		}

		// Assign home directory
		if ($this->reg_assignDir)
		{
			$objHomeDir = FilesModel::findByUuid($this->reg_homeDir);

			if ($objHomeDir !== null)
			{
				$this->import(Files::class, 'Files');
				$strUserDir = StringUtil::standardize($arrData['username']) ?: 'user_' . $objNewUser->id;

				// Add the user ID if the directory exists
				while (is_dir(System::getContainer()->getParameter('kernel.project_dir') . '/' . $objHomeDir->path . '/' . $strUserDir))
				{
					$strUserDir .= '_' . $objNewUser->id;
				}

				// Create the user folder
				new Folder($objHomeDir->path . '/' . $strUserDir);

				$objUserDir = FilesModel::findByPath($objHomeDir->path . '/' . $strUserDir);

				// Save the folder ID
				$objNewUser->assignDir = 1;
				$objNewUser->homeDir = $objUserDir->uuid;
				$objNewUser->save();
			}
		}

		// HOOK: send insert ID and user data
		if (isset($GLOBALS['TL_HOOKS']['createNewUser']) && \is_array($GLOBALS['TL_HOOKS']['createNewUser']))
		{
			foreach ($GLOBALS['TL_HOOKS']['createNewUser'] as $callback)
			{
				$this->import($callback[0]);
				$this->{$callback[0]}->{$callback[1]}($objNewUser->id, $arrData, $this);
			}
		}

		// Create the initial version (see #7816)
		$objVersions = new Versions('tl_member', $objNewUser->id);
		$objVersions->setUsername($objNewUser->username);
		$objVersions->setUserId(0);
		$objVersions->setEditUrl('contao/main.php?do=member&act=edit&id=%s&rt=1');
		$objVersions->initialize();

		// Inform admin if no activation link is sent
		if (!$this->reg_activate)
		{
			$this->sendAdminNotification($objNewUser->id, $arrData);
		}

		// Check whether there is a jumpTo page
		if (($objJumpTo = $this->objModel->getRelated('jumpTo')) instanceof PageModel)
		{
			$this->jumpToOrReload($objJumpTo->row());
		}

		$this->reload();
	}
protected function createNewUser($arrData)
	{
		$arrData['tstamp'] = time();
		$arrData['login'] = $this->reg_allowLogin;
		$arrData['dateAdded'] = $arrData['tstamp'];

		
		if (!\array_key_exists('groups', $arrData))
		{
			$arrData['groups'] = $this->reg_groups;
		}

		
		$arrData['disable'] = 1;

		
		if (isset($arrData['newsletter']) && !\is_array($arrData['newsletter']))
		{
			$arrData['newsletter'] = array($arrData['newsletter']);
		}

		
		$objNewUser = new MemberModel();
		$objNewUser->setRow($arrData);
		$objNewUser->save();

		
		$arrData['id'] = $objNewUser->id;

		
		if ($this->reg_activate)
		{
			$this->sendActivationMail($arrData);
		}

		
		if ($this->reg_assignDir)
		{
			$objHomeDir = FilesModel::findByUuid($this->reg_homeDir);

			if ($objHomeDir !== null)
			{
				$this->import(Files::class, 'Files');
				$strUserDir = StringUtil::standardize($arrData['username']) ?: 'user_' . $objNewUser->id;

				
				while (is_dir(System::getContainer()->getParameter('kernel.project_dir') . '/' . $objHomeDir->path . '/' . $strUserDir))
				{
					$strUserDir .= '_' . $objNewUser->id;
				}

				
				new Folder($objHomeDir->path . '/' . $strUserDir);

				$objUserDir = FilesModel::findByPath($objHomeDir->path . '/' . $strUserDir);

				
				$objNewUser->assignDir = 1;
				$objNewUser->homeDir = $objUserDir->uuid;
				$objNewUser->save();
			}
		}

		
		if (isset($GLOBALS['TL_HOOKS']['createNewUser']) && \is_array($GLOBALS['TL_HOOKS']['createNewUser']))
		{
			foreach ($GLOBALS['TL_HOOKS']['createNewUser'] as $callback)
			{
				$this->import($callback[0]);
				$this->{$callback[0]}->{$callback[1]}($objNewUser->id, $arrData, $this);
			}
		}

		
		$objVersions = new Versions('tl_member', $objNewUser->id);
		$objVersions->setUsername($objNewUser->username);
		$objVersions->setUserId(0);
		$objVersions->setEditUrl('contao/main.php?do=member&act=edit&id=%s&rt=1');
		$objVersions->initialize();

		
		if (!$this->reg_activate)
		{
			$this->sendAdminNotification($objNewUser->id, $arrData);
		}

		
		if (($objJumpTo = $this->objModel->getRelated('jumpTo')) instanceof PageModel)
		{
			$this->jumpToOrReload($objJumpTo->row());
		}

		$this->reload();
	}
protected function createNewUser ( $ arrData ) { $ arrData [ 'tstamp' ] = time ( ) ; $ arrData [ 'login' ] = $ this -> reg_allowLogin ; $ arrData [ 'dateAdded' ] = $ arrData [ 'tstamp' ] ; // Set default groups if ( ! \ array_key_exists ( 'groups' , $ arrData ) ) { $ arrData [ 'groups' ] = $ this -> reg_groups ; } // Disable account $ arrData [ 'disable' ] = 1 ; // Make sure newsletter is an array if ( isset ( $ arrData [ 'newsletter' ] ) && ! \ is_array ( $ arrData [ 'newsletter' ] ) ) { $ arrData [ 'newsletter' ] = array ( $ arrData [ 'newsletter' ] ) ; } // Create the user $ objNewUser = new MemberModel ( ) ; $ objNewUser -> setRow ( $ arrData ) ; $ objNewUser -> save ( ) ; // Store the new ID (see https://github.com/contao/contao/pull/196#discussion_r243555399) $ arrData [ 'id' ] = $ objNewUser -> id ; // Send activation e-mail if ( $ this -> reg_activate ) { $ this -> sendActivationMail ( $ arrData ) ; } // Assign home directory if ( $ this -> reg_assignDir ) { $ objHomeDir = FilesModel :: findByUuid ( $ this -> reg_homeDir ) ; if ( $ objHomeDir !== null ) { $ this -> import ( Files :: class , 'Files' ) ; $ strUserDir = StringUtil :: standardize ( $ arrData [ 'username' ] ) ? : 'user_' . $ objNewUser -> id ; // Add the user ID if the directory exists while ( is_dir ( System :: getContainer ( ) -> getParameter ( 'kernel.project_dir' ) . '/' . $ objHomeDir -> path . '/' . $ strUserDir ) ) { $ strUserDir .= '_' . $ objNewUser -> id ; } // Create the user folder new Folder ( $ objHomeDir -> path . '/' . $ strUserDir ) ; $ objUserDir = FilesModel :: findByPath ( $ objHomeDir -> path . '/' . $ strUserDir ) ; // Save the folder ID $ objNewUser -> assignDir = 1 ; $ objNewUser -> homeDir = $ objUserDir -> uuid ; $ objNewUser -> save ( ) ; } } // HOOK: send insert ID and user data if ( isset ( $ GLOBALS [ 'TL_HOOKS' ] [ 'createNewUser' ] ) && \ is_array ( $ GLOBALS [ 'TL_HOOKS' ] [ 'createNewUser' ] ) ) { foreach ( $ GLOBALS [ 'TL_HOOKS' ] [ 'createNewUser' ] as $ callback ) { $ this -> import ( $ callback [ 0 ] ) ; $ this -> { $ callback [ 0 ] } -> { $ callback [ 1 ] } ( $ objNewUser -> id , $ arrData , $ this ) ; } } // Create the initial version (see #7816) $ objVersions = new Versions ( 'tl_member' , $ objNewUser -> id ) ; $ objVersions -> setUsername ( $ objNewUser -> username ) ; $ objVersions -> setUserId ( 0 ) ; $ objVersions -> setEditUrl ( 'contao/main.php?do=member&act=edit&id=%s&rt=1' ) ; $ objVersions -> initialize ( ) ; // Inform admin if no activation link is sent if ( ! $ this -> reg_activate ) { $ this -> sendAdminNotification ( $ objNewUser -> id , $ arrData ) ; } // Check whether there is a jumpTo page if ( ( $ objJumpTo = $ this -> objModel -> getRelated ( 'jumpTo' ) ) instanceof PageModel ) { $ this -> jumpToOrReload ( $ objJumpTo -> row ( ) ) ; } $ this -> reload ( ) ; }
Create a new user and redirect

@param array $arrData
Create a new user and redirect