How to remove affiliates

If you want to remove affiliates via API, you can use method deleteRows in class Pap_Merchants_User_AffiliateForm.
Deleting an affiliate will cause all his data (commissions, clicks, payout history, reports, etc...) to be deleted as well!

Here is an example:
<?php

include 'PapApi.class.php'; //the PapApi.class.php can be found in your Post Affiliate Pro merchant panel>tools>Integration>API integration
$session = new Pap_Api_Session("https://URL_OF_YOUR_POST_AFFILIATE_PRO_ACCOUNT/scripts/server.php");
if(!$session->login("MERCHANT_USERNAME","MERCHANT_PASSWORD")) { 
  die("Cannot login. Message: ". $session->getMessage());
}

$userIds = array('11111111','6f4936c8'); //delete affiliates with these userIDs

$request = new Gpf_Rpc_Request("Pap_Merchants_User_AffiliateForm", "deleteRows", $session);
$request->addParam('ids', new Gpf_Rpc_Array($userIds));
$request->addParam('moveChildAffiliates', 'N'); // 'N' means that sub-affiliates of deleted affiliates won't be moved up in the affiliate tree
try {
  $request->sendNow();
}
catch(Exception $e) {
  die("API call error: ".$e->getMessage());
}

$response = $request->getStdResponse();
if ($response->success == 'Y') {
  echo 'Success: ' . $response->infoMessage;
}
else {
  echo 'Error: ' . $response->errorMessage;
}
?>
×