0
votes

I have an Entity called User that implements UserInterface, so it has the method getRoles():

function getRoles() { return array('ROLE_CLIENT'); }

Is it possible, once the user has been created, to add another role to that user?

1

1 Answers

0
votes

Use __construct method for adding user role by default

// Your user entity
class User {

    public function __constuct() {
        $this->roles = array(
            'ROLE_CLIENT', // or other roles
        );
    }

}

or in action of controller where you create new user add any roles to them.