Hi guys,
I'm trying to make it so that once a paid subscription is processed, my users reputation points are automatically updated to reflect the subscription they've bought (as well as their primary usergroup being upgraded).
I have 2 subscriptions set up.
Subscription 1 = 20 rep points
Subscription 2 = 50 rep points
Ok here's the idea for my (pseudo-) code. This would go at the end of payment_gateway.php if I'm not mistaken....
Code:
SELECT * from subscriptionlog WHERE userid=$userid AND status=1
// This gets all info about the subscription where the status denotes it as active (therefore if a user has previous expired subscriptions it won't grab them)
switch
case=1 {
SELECT * from user WHERE userid=$userid;
$newreputation = $row['reputation']+20;
UPDATE user SET reputation=$newreputation, usergroupid=10 WHERE userid=$userid;
{
case=2{
SELECT * from user WHERE userid=$userid;
$newreputation = $row['reputation']+50;
UPDATE user SET reputation=$newreputation, usergroupid=10 WHERE userid=$userid;
default;
//Something went wrong, do nothing;
Would this work or do I need extra error checking to make sure failed transactions aren't included in this??
Many thanks in advance, I'm quite desperate for this!
DoA