1
Groover
Dynamically changing user group
  • 2004/7/12 20:49

  • Groover

  • Just popping in

  • Posts: 23

  • Since: 2004/7/1 2


In the script that is called by paypal to confirm a purchase, I would like to change the group of a user while they are still logged in. Including header.php seems to stop paypal from calling the script, so I am doing everything with basic PHP MySQL queries.

The problem is that I run an update query to change the user's group. That works. However the visible/invisible blocks do not update on page loads to reflect the new group. For example:

Basic Users can see block 1 only
Advanced Users can see block 2 only

The user is a basic User and can see block 1.
Paypal calls the script that changes the user to an advanced user.
The user browses the site but can still see only block 1.

Do I need to do something else in the database besides change the table that links groups and users? Any help would be appriciated! Thanks!

Groover

2
Mithrandir
Re: Dynamically changing user group

Users' groups are updated on login and saved in a session variable, so get the users to logout and log back in.

3
intel352
Re: Dynamically changing user group
  • 2004/7/12 20:57

  • intel352

  • Module Developer

  • Posts: 824

  • Since: 2003/11/23


is the group entry in the database being properly changed?

btw, for your ipn script, check out my project, Donations (v1.4) http://dev.xoops.org/modules/xfmod/project/showfiles.php?group_id=1060


one of the dev.xoops.org programmers provided a stripped down common.php file, which is what i use in my ipn script, to avoid XOOPS restrictions. it might be of use.

4
Groover
Re: Dynamically changing user group
  • 2004/7/12 21:06

  • Groover

  • Just popping in

  • Posts: 23

  • Since: 2004/7/1 2


Thanks! Do you know the details or where I can find the details of the session/cookie variable that is used - because I can update that in my script without having the user log out.

I'll look at the donations module - Thanks!

Groover

5
intel352
Re: Dynamically changing user group
  • 2004/7/12 21:09

  • intel352

  • Module Developer

  • Posts: 824

  • Since: 2003/11/23


i'm not aware of the groups access level being stored in the user cookie, so if that's the case, you'll probably have to search the docs. or possibly just regenerate their cookie (keep in mind that sessions are often used as well. i don't work with cookies/sessions too much, so i'm not sure if that'll matter)

6
Mithrandir
Re: Dynamically changing user group

$HTTP_SESSION_VARS['xoopsUserGroups'] = $array_of_groups;

the $array_of_groups should be on the form $key => $groupid

7
Groover
Re: Dynamically changing user group
  • 2004/7/12 21:52

  • Groover

  • Just popping in

  • Posts: 23

  • Since: 2004/7/1 2


Well I tried it but it didn't work.....because my paypal IPN script is not part of the session stuff - it is not connected to a session - then I cannot modify HTTP_SESSION_VARS. So I will just have to make the user log out. Thanks for the help!

Groover

8
intel352
Re: Dynamically changing user group
  • 2004/7/12 21:58

  • intel352

  • Module Developer

  • Posts: 824

  • Since: 2003/11/23


yes, that makes sense, because the IPN notification isn't always immediate and is actually a communication between the paypal server and the webserver, no user intervention

9
Groover
Re: Dynamically changing user group
  • 2004/7/12 23:06

  • Groover

  • Just popping in

  • Posts: 23

  • Since: 2004/7/1 2


I found a workaround that is acceptable for me. I have auto return turned on in paypal. On the auto return page, if the user is logged in then I update HTTP_SESSION_VARS['xoopsUserGroups'][0] with the user's current groupid. I also advise them that they might have to log out.

The result is that the Paypal IPN is usually sent before the auto return page is displayed, so the user's session is updated to switch to the new group.

Groover

Login

Who's Online

411 user(s) are online (132 user(s) are browsing Support Forums)


Members: 0


Guests: 411


more...

Donat-O-Meter

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

Latest GitHub Commits