title: PHP (Moodle) variables $USER->name used in queries
body: <p><strong>Background:</strong>
  On our site students are enrolling themselves via an automated system in another CMS and only username, email and password are set up. This means their first and last name are something like 'default' or whatever but this needs to be changed - students need to be forced to change their details on log in.</p>
  
  <p><strong>Problem:</strong>
  I was writing some code that did a header redirect:</p>
  
  <pre><code>if($PAGE-&gt;title != "Edit Profile" &amp;&amp; $USER-&gt;lastname = "changeme") 
  {header( 'Location: http://www.example.com/user/edit.php' )}
  </code></pre>
  
  <p>However although this works for a few initial clicks, the lastname is changed back to "changeme" and thus the person is stuck on the edit profile page (edit.php).</p>
  
  <p>Is there a way I can get the lastname of the student as a variable so I can run the query if(lastname = "changeme") without the lastname being changed?</p>
  
  <p>Or is there another solution to the problem altogether? (getting the student to change First and Last name on first time entering the site?</p>
  
  <p>thanks,</p>
  
  <p>Richard</p>