Add User Event Hook problem
Permalink
With the on_add_user event hook, I'm trying to have the system setup two new pages whenever a new user is created and is a member of the Clients group.
I have it down so that it'll setup the new pages, but I need to use a conditional to test if the user was put into the Clients group...
Here's the code I'm using
... But, the $groups variable always comes back empty (when it should be an array containing the groups)
Any ideas?
I have it down so that it'll setup the new pages, but I need to use a conditional to test if the user was put into the Clients group...
Here's the code I'm using
$uID = $ui->getUserID(); Loader::model('user'); $u = User::getByUserID($uID); $groups = $u->getUserGroups();
... But, the $groups variable always comes back empty (when it should be an array containing the groups)
Any ideas?
The list of groups a user is in is cached in session data. Depending how you are adding the group and what's going on between that and the code you noted, there may not have been a chance for the list to have been updated. Try adding a call to $u->refreshUserGroups() just before the getUserGroups() call.
You mind posting the code you used to add pages from the event hook?
this doc page might help you:
http://www.concrete5.org/help/building_with_concrete5/developers/mv...
http://www.concrete5.org/help/building_with_concrete5/developers/mv...