Norman Norman - 1 year ago 135
PHP Question

TYPO3: Create a FE user inside controller action

I'd like to create a FE user with a custom extension (created with the extension builder).
I don't want to use fe_user_registration or something similar because there are also many other custom features needed which will probably be lost when some moron accidentally updates it.

I'm using TYPO3 7.6.8

Answer Source

Extbase comes with a model and a repository for manipulating frontend users. They also have a model and a repository for dealing with frontend user groups.

Use those, in the usual way. You might need to fiddle a bit to get storage pages right, but it'll work. I'm not sure if the password will be hashed automatically, so check that out.

First, inject a FrontendUserRepository where you want to use it:

 * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
 * @inject
protected $frontendUserRepository;

Then create a frontend user and persist it using the repository:

$frontendUser = new FrontendUser();
// Set more values

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download