Hi everyone, I can't find a way how to set up a custom script for each product individually. It is expected to run at the moment of the sign up and some vars should be passed to the php script. for example the 3 Months subscription would run this: www.mysite.com/myscript.php?username=john&product=3months&product_quantity=3 Any suggestion would be highly appreciated!
You can use site.php file to put code for such customization (http://www.amember.com/docs/Site.php_file) so it will not be overwritten during upgrade. Here is complete example of code to achieve your needs: Code: Am_Di::getInstance()->hook->add(Am_Event::ACCESS_AFTER_INSERT, 'myAccessHandler'); function myAccessHandler(Am_Event $event) { /* @var $access Access */ $access = $event->getAccess(); /* @var $user User */ $user = $event->getUser(); $request = new Am_HttpRequest('http://www.mysite.com/myscript.php?' . http_build_query(array( 'username' => $user->login, 'product_id' => $access->product_id, 'product_quantity' => $access->qty )), Am_HttpRequest::METHOD_GET); $request->send(); }
Hi Caesar, I get along with this well, just a quick question... what am I missing in this short code in order to echo the id of the product what the user has? <p>product: <?php $myCode = Am_Di::getInstance()->user->getActiveProducts(); echo $myCode[product_id];?> </p> <p>product: <?php $myCode = Am_Di::getInstance()->user->getActiveProductIds(); echo $myCode[product_id];?> </p> Thanks for your support!
Hey, In your case $myCode will be array of product ids. So in case you want to output first element you can use Code: echo $myCode[0];
Thanks works fine! I also need direction for a similar one because it returns nothing: Is this line correct? my_invoice: "<?php $myInvoice = Am_Lite::getInstance()->getPayments(); echo $myInvoice[invoice]; ?>
This code Am_Lite::getInstance()->getPayments() return array of user's payments (of currently logged in user). I recommend you to debug output of this function to understand how it works. So please use print_r(Am_Lite::getInstance()->getPayments()). You will see result of this method call and will be able to retrieve necessary info from it.
All right it makes sense, but as far as I can see it returns nothing but the product_id and quantity, nothing user related infos (using FastSpring payments made on payment system side) Am I right? Your answer may save my whole day
Am_Lite::getInstance()->getPayments() return array of payments associated with currently logged in user. Each item in this array is array too with info for payment.