Body: <p>I have a plugin that does a little work after a user has been saved in the CP based on the user groups they are in.</p>
  
  <p>The $event->params['user'] object seems to be partially up to date when the event is handled. The username and general info is the recently entered values, however the groups is not current, it is always what is was before</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-08-26T21:18:21.433Z
Comments.Text: I did a little extra digging, if I kill the function that is handling the onSaveUser event and check the database the craft_usergroups_user table is showing the 'old' values, not the values that were just posted.
Comments.UserDisplayName: Derrick Grigg
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-08-26T23:12:26.940Z
Comments.Text: There is a known issue regarding the `$_POST['groups']` value, and the order in which it's processed. This [answer from another question](http://craftcms.stackexchange.com/a/1986/45) addresses a slightly different situation, but may help you solve your problem.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-05T13:51:08.087Z
Comments.Text: Thanks @LindseyD. I ended up checking the groups array in the post to see if the correct value was there `$groups = craft()->request->getPost('groups');`
Comments.UserDisplayName: Derrick Grigg
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-20T01:05:50.397Z
Comments.Text: I'm voting to close this question as off-topic because it sounds like a bug that you hit and you aren't posing a specific question. Feel free to clarify if this isn't the case.
Comments.UserDisplayName: Anna_MediaGirl
Tags: <plugin-development><users><events>
Title: users.onSaveUser groups out of sync
ThreadText: # users.onSaveUser groups out of sync
  
  (Asked by: username_0 on 2014-08-26)
  
  I have a plugin that does a little work after a user has been saved in the CP based on the user groups they are in.
  
  The $event->params['user'] object seems to be partially up to date when the event is handled. The username and general info is the recently entered values, however the groups is not current, it is always what is was before
  
  **Tags:** plugin-development, users, events
  
  > **Comments:**
  > **username_0**: I did a little extra digging, if I kill the function that is handling the onSaveUser event and check the database the craft_usergroups_user table is showing the 'old' values, not the values that were just posted.  
  > **username_1**: There is a known issue regarding the `$_POST['groups']` value, and the order in which it's processed. This [answer from another question](http://craftcms.stackexchange.com/a/1986/45) addresses a slightly different situation, but may help you solve your problem.  
  > **username_0**: Thanks @username_1. I ended up checking the groups array in the post to see if the correct value was there `$groups = craft()->request->getPost('groups');`  
  > **username_2**: I'm voting to close this question as off-topic because it sounds like a bug that you hit and you aren't posing a specific question. Feel free to clarify if this isn't the case.  
  
  ---
  
  ## 0 answers
  
  