Add user to group when they visit a certain page.

Permalink
Is it possible to add a user to a particular group when they visit a specific page? How could I set this up?

EDIT: I was able to get the user added to the group by doing this:

$g = Group::getByID(5);
$u = new User();
$u->enterGroup($g);


However, my goal in doing this was to remove the user's access to a certain page by adding them to a group that won't allow them to visit that page. They are being added to that group just fine now but they are still able to access the restricted page until they logout. After logging out and then logging back in, they can no longer access the page but I need the page to be restricted before logging out.

How can I get the permissions to go into affect immediately? The group is being assigned immediately but the permissions of that group for that user aren't going into affect until after logging out and then logging back in.

Thoughts?

Thanks.

 
TNTdesign replied on at Permalink Reply
So, I ended up just forcing a logout with /login/logout which reset the permissions. Not super user friendly but for what I'm trying to do, it'll be fine. Thanks.