title: symfony 3: how to add role to specific user
body: <p>It looks pretty simple and I'm a begginer with Symfony, but couldn't figure it out.</p>
  
  <p>I'm using FOSUserBundle, and I'm trying to add a specific role (ROLE_ADMIN) to a specific user (e.g. me), so when the user logs in that role is assigned and he can access certain pages.</p>
  
  <p>I tried putting something like this in the <code>__construct()</code> method of my User entity, but it didn't work:</p>
  
  <pre><code>if($this-&gt;getUsername()=='johndoe') $this-&gt;addRole('ROLE_ADMIN');
  </code></pre>
  
  <p>When I log in as that user, the debugging utilities show only the 'ROLE_USER', os it is not working.</p>
  
  <p>Is that a right code? Where should I put it?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>There was a silly error that accidentally found. I had created the User entity before isntalling FOSUserBundle, and somehow the user I was trying to promote gave me errors through CLI. Maybe it wasn't properly stored in the database. Once I created a new one and tried again, the command worked as expected.</p>