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:
//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...
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...

Login

Who's Online

450 user(s) are online (343 user(s) are browsing Support Forums)


Members: 0


Guests: 450


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits