Quote from: BobRay at Jun 18, 2014, 09:23 PMI'm glad you got it sorted. Thanks for reporting back.
All of a sudden, as soon as I transferred over from .sandbox.paypal, it no longer works! (And I have no idea why!)
I've setup some echos, and it's running in the part where the user should be added to the usergroup, so I'm not quite sure what's wrong!
<?php
// Copyright Pixel Crescent 2014 All Rights Reserved
// This initialises all MODx Commands and Permissions! :D
error_reporting(E_ALL);
require_once '../config.core.php';
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error','error.modError', '', '');
function userPurchasedItem($item_id, $payment_amount, $payer_email, $username) {
global $modx;
//mail('[email protected]', 'Just received a purchase!', 'The user: '.$username.' at '.$payer_email.' has just purchased an item for $'.$payment_amount.' ID: '.$item_id);
$myUser = $modx->getObject('modUser', array('username'=>$username));
if ($myUser) {
$myUser->save();
$myUser->joinGroup($item_id);
echo 'It is set!';
$cm = $modx->getCacheManager();
$cm->refresh();
} else {
mail('[email protected]', 'Error Assigning group', 'Something went wrong when assigning the user '.$username.' who purchased the item '.$item_id.' for'.$payment_amount);
die('No User');
}
}
?>
My test code that is running is:
<?php
include('userPurchase.php');
userPurchasedItem('4', '5', '[email protected]', 'muffinjello');
?>
And there is the user 'muffinjello' in my DB... never even touched that. Any ideas?