We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Could also check $modx->user if they are expected to be logged in while checking out.
      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
      • 20135
      • 188 Posts
      Thanks for getting back to me Mark, but I've found the solution I was looking for. Actually, reminding me that this was a relatively unsupported extra gave me confidence to go and edit the code to try and find what I was looking for. But, as it turns out, the solution doesn't require editing the original code, it can all be done in the hook snippet.

      So when MHPP runs any hook (pre, post, or postPayment), it packages the whole class (as an object) into an array, and send the array to the hook snippet - this can be accessed in the hook snippet by using the MODx global $scriptProperties. The object then also contains another array named 'data', containing the information that's been retrieved from the cache as well as the payment data from Paypal. In my case, it contained the username field from the form. How to get this was the mystery.

      Luckily, Developer Tools helped me see the whole html from outputting $scriptProperties, showing me the type of variables in play - the container as an array, the mhpp object and the data array right at the bottom. To access the username from the data array, I needed to put the pieces togethe in the hook snippet (here's the whole snippet, with Bruno's original suggestion included):
      $un = $scriptProperties['mhpp']->data['uname'];
      $user = $modx->getObject('modUser', array('username'=>$un));
      return true;

      Once I had got the hang of calling array or object, it fell into place quite easily. Of course, any of the config or other items from the mhpp class can be easily accessed via this way.

      Thanks everyone for your input, particularly Bruno - maybe this will help someone in the future. And thanks Mark for the snippet, it does work well - you should continue to develop it.
        • 46886
        • 1,154 Posts
        So cool, you saw the way and went for it. Conceptually its so smooth. Good work!