Reputation: 1962
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?
Upvotes: 1
Views: 5087
Reputation: 1962
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()
Upvotes: 4