I'm currently working on a project that requires me to give some users the ability to edit other users and place users in one of two groups. I am currently having them use the dashboard user editor but do not want them to have access to groups because they would then be allowed to place themselves or anyone else into the administrator group. To get around this I have defined check-box attributes for the two groups that I want the users to be allowed in, and created an event library to place the users in the groups based on those attributes, whenever a new user is created or updated. The event is triggering properly as I am having it generate a log so I know that it's getting to the code that should put the user into the group, however my problem is that it does not actually place the user in the group!
Here is my code which is in the extension of (on_user_update), can anyone see anything wrong with this?
$u= User::getByUserID($user->getUserID());$agroup1=$user->getAttribute('group1');$agroup2=$user->getAttribute('group2');//checks my group attributes$l=newLog('AutoGroup',true);$l->write('Group1 = '.$agroup1.' Group2 = '.$agroup2.' UserID = '.$user->getUserID());//remove from group1 if attribute checkedif($agroup1==false){$u->exitGroup(Group::getByName('Group1'));$l->write('Removed '.$user->getUserName().' from Group1 via attribute.');}//add to group1 if attribute checkedif($agroup1==true){$u->enterGroup(Group::getByName('Group1'));$l->write('Added '.$user->getUserName().' to Group1 via attribute.');
$u= User::getByUserID($user->getUserID());$agroup1=$user->getAttribute('group1');$agroup2=$user->getAttribute('group2');//checks my group attributes$l=newLog('AutoGroup',true);$l->write('Group1 = '.$agroup1.' Group2 = '.$agroup2.' UserID = '.$user->getUserID());//remove from group1 if attribute checkedif($agroup1==false){$u->exitGroup(Group::getByName('Group1'));$l->write('Removed '.$user->getUserName().' from Group1 via attribute.');}//add to group1 if attribute checkedif($agroup1==true){$u->enterGroup(Group::getByName('Group1'));$l->write('Added '.$user->getUserName().' to Group1 via attribute.');}
The code runs through fine, no php errors, and here's my log
Group1 =1 Group2 =0 UserID =11
Added username to Group1 via attribute.
So I'm wondering is there a library or a helper that needs to be loaded to do this properly because I'm just beyond confused by this at this point. And thanks in advance for any help.
Code
Post Reply
Delete Post
You are allowed to delete your post for 5 minutes after it's posted.
This website stores cookies on your computer. These cookies are used to improve
your website experience and provide more personalized services to you, both on this website and through
other media. To find out more about the cookies we use, see our Privacy Policy.