Change User's User Group on Form Submit Without Force Logout

What function are you using to add/remove group membership?

Iirc, in J! 3.x, using /...

JUserHelper::addUserToGroup( $userId, $groupId );
JUserHelper::removeUserFromGroup( $userId, $groupId );

... should change their groups without requiring a logout.

-- hugh
 
What function are you using to add/remove group membership?

Iirc, in J! 3.x, using /...

JUserHelper::addUserToGroup( $userId, $groupId );
JUserHelper::removeUserFromGroup( $userId, $groupId );

... should change their groups without requiring a logout.

-- hugh

Thanks Hugh for the clarification. I was using addUserToGroup but I had the below code following that, that I pulled from a post within the forums and that looks to be the culprit. I've removed that and it's working correctly now. Thanks again!
Code:
$session = JFactory::getSession();
$session->set('user', new JUser($user->get('id')));
 
Yeah, I think that was needed in earlier versions of J!, but addUserToGroup() now handles updating the session internally.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top