How do you remove a user from a group programmatically?
Posted: Wed Jun 29, 2011 11:41 am
Im able to add a user to a group, but seems that removing a user from a group at runtime looks like it works but is not saved to the database.
Here's what I am using to test with:
I have code right afterwards that enumerates all of the users' groups, and sure enough 9 is removed - but If i comment it out and load it up 9 is back. How can I save it after I remove it?
Here's what I am using to test with:
Code: Select all
Token.Instance.User.UserGroups.RemoveAt(Token.Instance.User.UserGroups.IndexOf(Token.Instance.User.UserId, 9));
Token.Instance.User.UserGroups.Save();
Token.Instance.User.Save();