1
andersa
Switching a user between two groups
  • 2004/7/15 12:07

  • andersa

  • Just popping in

  • Posts: 45

  • Since: 2004/5/27


I have two groups which I know has IDs 4 and 5. I am trying to switch a user between the two groups with this code:

Quote:

$member_handler =& xoops_gethandler('member');

$result = $member_handler->removeUsersFromGroup(4,array($xoopsUser->getVar('uid')));
$member_handler->addUserToGroup(5,$xoopsUser->getVar('uid'));


I know for sure the first call fails ($result is False), and the user doesn't get added to the second group either, so I guess that fails too. But can anyone see why?

2
Dave_L
Re: Switching a user between two groups
  • 2004/7/15 12:47

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Is PHP debug on, and are you sure $xoopsUser is defined at that point? I would add this to the beginning of that code, for debugging:

error_reporting(E_ALL);
echo 
is_object($xoopsUser) ? 'xoopsUser IS defined' 'xoopsUser is NOT defined';

3
ackbarr
Re: Switching a user between two groups

these calls fail because the XoopsMySQLDatabaseSafe::Query() function will only perform an insert, update, or delete query when called from a POSTed form. If you turn on MySQL debugging you should see those queries flagged in red.

4
andersa
Re: Switching a user between two groups
  • 2004/7/15 19:35

  • andersa

  • Just popping in

  • Posts: 45

  • Since: 2004/5/27


Ah! It took a bit of work to convert the module to using forms, so I could do post the form. I was just using get.

I've got my module up and running now! Thanks!

5
bluwu
Re: Switching a user between two groups
  • 2004/9/11 0:05

  • bluwu

  • Just popping in

  • Posts: 26

  • Since: 2004/6/29


Quote:

ackbarr wrote:
these calls fail because the XoopsMySQLDatabaseSafe::Query() function will only perform an insert, update, or delete query when called from a POSTed form. If you turn on MySQL debugging you should see those queries flagged in red.

Knowing about the safety feature of XoopsMySQLDatabaseSafe::Query() function, is there a way to update without a FORM. I would like not to use a form in my scenario.



6
ackbarr
Re: Switching a user between two groups

XoopsMySQLDatabaseSafe::QueryF() will work without a form, it forces the query to run, bypassing the safety checks.

7
bluwu
Re: Switching a user between two groups
  • 2004/9/11 0:50

  • bluwu

  • Just popping in

  • Posts: 26

  • Since: 2004/6/29


Quote:

ackbarr wrote:
XoopsMySQLDatabaseSafe::QueryF() will work without a form, it forces the query to run, bypassing the safety checks.


Thanks for responding

8
bluwu
Re: Switching a user between two groups
  • 2004/9/11 1:02

  • bluwu

  • Just popping in

  • Posts: 26

  • Since: 2004/6/29


Is there an argument I can pass to tell addUsertoGroup (or other function) to force?

Nevermind.... Looks like I found it...

Like coolsville man.

9
bluwu
logout/login after switching a user between two groups?
  • 2004/9/14 23:57

  • bluwu

  • Just popping in

  • Posts: 26

  • Since: 2004/6/29


When you switch a user between groups (adding to group etc.) does a user have to log out in order to have his new permissions kick in?


Login

Who's Online

324 user(s) are online (63 user(s) are browsing Support Forums)


Members: 0


Guests: 324


more...

Donat-O-Meter

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

Latest GitHub Commits