<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>

CC BY-SA 3.0
2014-08-26T21:18:21.433Z
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.
Derrick Grigg
CC BY-SA 3.0
2014-08-26T23:12:26.940Z
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.
Lindsey D
CC BY-SA 3.0
2014-09-05T13:51:08.087Z
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');`
Derrick Grigg
CC BY-SA 3.0
2015-02-20T01:05:50.397Z
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.
Anna_MediaGirl
<plugin-development><users><events>
users.onSaveUser groups out of sync
# 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 @LindseyD. 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

