1
punches
How to change member's group using Xoops' API?
  • 2004/12/5 13:01

  • punches

  • Just popping in

  • Posts: 6

  • Since: 2004/7/12


I'm creating a module for XOOPS 2. Sometimes I need to delete a user from one group and put it in another. How can I do it using Xoops' API?

2
ackbarr
Re: How to change member's group using Xoops' API?

the addUserToGroup and removeUsersFromGroup functions in the XoopsMemberHandler class should do the trick

Example Usage:
le="color: #000000"><?php //Assumes that the user id is stored in the var $uid //Assumes that the groupid is stored in the var $groupid //Get an instance of the XoopsMemberHandler class $hMember =& xoops_gethandler('member'); //Add the user to a specific group //Returns a XoopsMembership object $membership =& $hMember->addUserToGroup($uid, $groupid); //Remove the user from a specific group $hMember->removeUsersFromGroup($groupid, array($uid));

3
sinus
Re: How to change members group using Xoops API?
  • 2005/7/19 9:33

  • sinus

  • Just popping in

  • Posts: 27

  • Since: 2005/6/11


hmmm...
i am having problems adding a uid to a group id...
le="color: #000000"><?php if (!$member_handler->insertUser($newuser,true)) { //$adduser_errormsg = _AM_CNRNU; echo "error inserting new user to xoops_users"; } else { if (!$member_handler->addUserToGroup('2', $newuser->getVar('uid'))) { //$adduser_errormsg = _AM_CNRNU2; echo "error adding uid: ".$newuser->getVar('uid')." to group table"; } }


any idea why it wont? we have been debugging it for awhile now... it always fails...