I'm creating an extension for visitors to sign up to the page.
When signing up, it should create a FE user in the backend which is disabled (and will be manually enabled by an admin). So I'll need to set the disable
field to 1
when creating the FE user.
This is the function inside my controller:
/**
* action create
*
* @param \Vendor\FeReg\Domain\Model\Dummy $newDummy
* @return void
*/
public function createAction(\Vendor\FeReg\Domain\Model\Dummy $newDummy)
{
// vars
$title = $newDummy->getTitle();
$atitle = $newDummy->getAtitle();
$fname = $newDummy->getFname();
$lname = $newDummy->getLname();
$street = $newDummy->getStreet();
$city = $newDummy->getCity();
$post = $newDummy->getPost();
$phone = $newDummy->getPhone();
$fax = $newDummy->getFax();
$email = $newDummy->getEmail();
$org = $newDummy->getOrg();
$cat = $newDummy->getCat();
$field = $newDummy->getField();
$uname = $newDummy->getUname();
$ppass = $newDummy->getPpass();
$cpass = $newDummy->getCpass();
$fulltitle = ($atitle ? $title." ".$atitle : $title);
$frontendUser = new FrontendUser();
$frontendUser->setUsername($uname);
$frontendUser->setPassword($ppass);
$frontendUser->setFirstname($fname);
$frontendUser->setLastname($lname);
$frontendUser->setAddress($street);
$frontendUser->setTelephone($phone);
$frontendUser->setFax($fax);
$frontendUser->setEmail($email);
$frontendUser->setTitle($fulltitle);
$frontendUser->setZip($post);
$frontendUser->setCity($city);
$frontendUser->setCompany($org);
$this->frontendUserRepository->add($frontendUser);
// $this->dummyRepository->add($newDummy);
// $this->addFlashMessage($title, '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);
$this->redirect('new');
}
To make this work I'm also loading the $frontendUserRepository
.
I need something like $frontendUser->setDisable(1)
.
Environment: TYPO3 7.6.8 / PHP 5.6.24 / mysqlnd 5.0.11
Disabling a user is not default enabled on the standard user object. I've tackled this issue myself by creating a model extending the FrontendUser from TYPO3 and adding a property disable.
You might need a bit of typoscript to map it to the proper property
You'll need the FrontendUserRepository as well
After this you can use the newly created FrontendUser model as your model for the FrontendUser, inject it, and happily use
(All namespaces are fully written, this is not necessary obviously, but simply done for ease of reading)