Here’s my scenario:
My client offers 2 programs. Let’s call them Apples and Oranges.
The Apples program is sold to organizations, totally separate from the website. The client then manually registers the members, who are put in the Apples group. They have access only to the Apples template.
The Oranges program is sold through the site. Since Simple Commerce can’t do PayPal subscriptions, I have the PayPal code generated from the subscription button on the PayPal site in the template. They click to subscribe, pay on the PayPal site, and then I send them back to our site to a “Thank You” page, which gives them a link to register. When they register, they are put in the Oranges group.
The Oranges group can see everything in their group, plus everything in the Apples group. All this works fine.
Here’s the bugaboo.
My client is marketing the Oranges program to the Apples group.
Since I can’t have members in multiple groups (which would solve this problem), I need a way to change the group ID of an Apple member who purchases the Orange program.
I thought I would run an update query on the Thank You page, first using {if_logged_in} as a conditional.
The query I want is this:
UPDATE exp_members set group_id = ‘8’ where member_id = ‘{member_id}’
It works in phpMyAdmin, and from the SQL Query manager. I just can’t get it to work in the template, most likely because I’m coding it incorrectly because I don’t speak PHP very well.
So, some help on that would be appreciated.
The next step is figuring out if they are already registered on the site, because they might come and buy the Oranges program without ever logging in. If they try to register using their existing name and password, they’ll get an error.
So, on that same Thank You page, I thought I’d ask them if they are a member of the Apples group, and present the login form, and then return them to the same page, which I assumed would then run the update query and change their group because now they meet the conditional {if_logged_in}.
Is this approach stupid? Is there some easier way?
Thanks for any suggestions and the correct way to execute an update query in a template.