21
Ok, this is getting frustrating and I am about to bypass this and go directly to the database.
I decided to make a new function as below and not use the function as above.
The following function works right up until the lines where it actually is supposed to add or subtract a user from the user group. I have heavily commented this function to show what I am trying to do. I would greatly appreciate someone looking at it and seeing what I am missing.
$result returns a null which I would expect is a failure?
le="color: #000000"><?php /** $id is the $id of the user from the roster database * $action true = add user to group false = remove user from group * $xrosterList_users is list of registered users with the key being the UID and value being the UNAME * $key = contains the UID of the user obtained from the list of registered users * $xoopsModuleConfig['ugroup'] is the groupid of the group I am trying to add/remove user from * $result should equal true if it worked */ $xrosterhMember =& xoops_gethandler('member'); // Getting a handle for xoops_gethandler (doesn't seem to work if I put it IN the function) function Groups_Add_n_Remove($id, $action = 0) { $action = (int)$action ? 1 : 0; // making sure it is an int. 1 = add user 0 = remove user global $xrosterList_users, $xoopsModuleConfig, $xrosterhMember; $member=getMember($id, 1); // added the 1 to have getMember get a member no matter if activated or not and modified getMember accordingly $key = array_search($member['membername'], $xrosterList_users); // gets UID of user if user is a registered user on the site if ($key){ // makes sure the roster memeber is a registered site member if ($action) $result =& $xrosterhMember->addUserToGroup($xoopsModuleConfig['ugroup'], $key); // addUserToGroup('groupid', 'uid') else $result =& $xrosterhMember->removeUsersFromGroup($xoopsModuleConfig['ugroup'], array($key)); // removeUsersFromGroup('groupid', array('uid')) } }