how to add user roles dynamically upon login with symfony2 (and fosUserBundle)?
In my app users can switch between free user and premium user over time, when their subscription expires, they no longer have premium previleges. I thought I could cut a corner and not store the premium user role in the database, only store the date to which they have paid, thus eliminating the need for a cron job adding och removing the role premium from my users. The solution I had in mind was to do this on the user entity: public function __construct() { if ( $this->hasPlus() ) { $this->addRole('ROLE_PLUSUSER'); } } Where hasPlus is a function that compares the current date with the paid-to