title: MIXED_DML_OPERATION error in Salesforce Apex Trigger when updating User objects
body: <p>I have a trigger on a Contact object and when I try to update a User record in this trigger I get the following exception:</p>
  
  <p>"MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): User, original object: Contact"</p>
  
  <p>Trigger code:</p>
  
  <pre><code>trigger UpdateContactTrigger on Contact (after update) {
  
      User u = [SELECT Id, IsActive FROM User WHERE IsActive = true];
  
      u.IsActive = false;
      update u;
  
  }
  </code></pre>
  
  <p>How can I avoid this error while updating User record's fields from a Contact trigger?</p>