Hi I have an affiliate auto-creating users on my members system (indirectly, via our application API). What we want to do is identify if the user is new to us and if so, assign their affiliate id to that user. We are following the guide to adding a user via API here: http://www.amember.com/docs/REST_API_examples A few questions 1 - If the user already exists - will it be updated or will it be ignored? We prefer to ignore an existing user. 2 - Can we add the affiliate id to any newly created customers? If so - how do we do that? Which columns would we need to populate & what is the right data? Many thanks Peter
Hello, 1. In event of you will try to insert user with username that already exists then you get error 2. You need to set column aff_id to id of affiliate (user_id) Best Regards.
Thanks Caesar I am struggling with that. I think I did what you said.... PHP: public function CreateUser($empUsername,$empPassword,$empEmail,$empFirstName,$empLastName,$compUsername){ Log::info('create user '.$empUsername." Affiliate ".$compUsername); $url = $this->member_url_api.'users'; $key = self::$AUTH_KEY; $fields = array( '_key' => $key, 'login' => $empUsername, 'pass' => $empPassword, 'email' => $empEmail, 'name_f' => $empFirstName, 'name_l' => $empLastName, 'aff_id' => $compUsername, ); // Register new user to aMembersystem with REST API. $query = http_build_query($fields); $query = str_replace("%40", "@", $query); $header = array("Content-type: application/x-www-form-urlencoded"); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $query); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //execute post $result = curl_exec($ch); //close connection curl_close($ch); $jsonData = json_decode($result,true); if($jsonData){ $content = array_values($jsonData)[0]; if(is_array($content)){ return 'useradded'; } }else{ return 'apinotworking'; } } As you can see there's a log at the top. I ran it, the user got created perfectly but without an assigned affiliate. [2019-06-05 15:46:34] local.INFO: create user Test3001 Affiliate JigsawTrading User "JigsawTrading" is an assigned affiliate but the referred Affiliate is still empty Any ideas what is wrong? Cheers Pete