I have just about finished migrating all of my users/affiliates/commissions/payments and products over to Amember from digital access pass. all I need to do is intercept all the old affiliate links. I can detect the user id of the DAP user from the link vars and I can retrieve the Amember user from db using the additional field I added and set when I imported the users. now I am stuck on how to record the click and set a cookie. (I can record the click by manually like this after including /amember/bootstrap.php) Code: $query = Am_Di::getInstance()->db->query("INSERT INTO ?_aff_click SET aff_id=?d, time=?, banner_id=?d, remote_addr=?, referer=? ", $affiliate_id, date('Y-m-j H:M:i'), null, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_REFERER'] ); $clickid = Am_Di::getInstance()->db->selectCell("SELECT LAST_INSERT_ID()"); but that's not the best way I am sure! could you give me a pointer on how to record the click and set the cookie using Amember functions from the file I have placed in the same place as the old GO script that DAP uses? (this file is not part of Amember, it is external to any Amember plugins/modules) Once I have this in place, I will have fully moved from DAP -> Amember and would be happy to write a tutorial on the process
You can get an example in /amember/application/aff/controllers/GoController.php: PHP: $aff_click_id = $this->getDi()->affClickTable->log($this->aff, $this->banner); $this->getModule()->setCookie($this->aff, $this->banner ? $this->banner : null, $aff_click_id);
Thanks Alexander i already saw that but I need to do this in an external file so $this does not exist. How to initiate the proper class so I can use $this?
thanks so much for your help Alexander. I managed to get it working so I can convert the old Digital Access Pass affiliate links in to Amember affiliate links. here's my code if anyone else comes searching for this PHP: <?php /** affiliate link converter . * goes from DAP to Amember by detecting the affiliate id of DAP users link and tries to match * to the dapid that was saved to the users in amember that were imported. * * example link http://toolstomakemoney.com/dap/a/?a=1&p=www.example.com/somepage.html */ include_once "../../member/bootstrap.php"; $a = isset($_GET['a']) ? $_GET['a'] : ""; //a = DAP affiliate id $p = isset($_GET['p']) ? $_GET['p'] : "http://toolstomakemoney.com"; // get DAP URL or default to main site if($a){ // this is a DAP affiliate link, get AM user based on dapid (dapid is an additional sql field set when DAP users were imported) $affiliate_id = Am_Di::getInstance()->db->selectCell("SELECT user_id FROM ?_user WHERE dapid = ? LIMIT 1",$a); if($affiliate_id){ // there is a AM user for this DAP user. load the user $aff = Am_Di::getInstance()->userTable->load($affiliate_id, false); // record the click and set the cookie $aff_click_id = Am_Di::getInstance()->affClickTable->log($aff, null); Am_Di::getInstance()->modules->get('aff')->setCookie($aff, null, $aff_click_id); // forward to the URL supplied header("Location: $p"); } }?>
That "anyone else" was me. I don't like bumping old threads but I had to say THANK YOU, this is exactly what I needed. I had a similar script for v3 but my client updated to v4 and I needed to re-create it. Works perfectly! Scott