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

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

focus43
 
tbcrowe replied on at Permalink Reply
tbcrowe
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.
focus43 replied on at Permalink Reply
focus43
You mind posting the code you used to add pages from the event hook?
Tony replied on at Permalink Reply
Tony