问题描述
我确定这是一个简单的问题,但我看不到或找到正确的方法.
使用注册表格创建该用户时,如何向用户添加角色?
推荐答案
找到了它.我在正确的轨道上:)
覆盖注册表格处理程序.
blob/master/resources/doc/overriding_forms.md
添加
$user->addRole('ROLE_MYROLE');
之前
parent::onSuccess()
问题描述
I'm sure this is a simple question but I can't quite see or find the correct way to do it.
How do I add a role to a user when that user is created using the registration form?
推荐答案
Found it. I was on the right track :)
Override the registration form handler.
https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_forms.md
Add
$user->addRole('ROLE_MYROLE');
before
parent::onSuccess()