vbatra Posted May 6, 2019 Share Posted May 6, 2019 I am out of touch from WHMCS development for more than a year. I want to set all the newly signed up clients as an affiliate in WHCMS and created the following hook. The following code is saved as SetAsAffiliate.php in hooks directory. I assume that the code should run whenever there is a new client registration but it is not happening. Can someone please tell what am I missing? TIA. <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function SetAsAffiliate($vars) { $clientid = $vars['userid']; //Set the API parameter and vars $command = 'AffiliateActivate'; $values["user"] = $clientid; $results = localAPI($command, $values); } add_hook("ClientAreaRegister",1,"SetAsAffiliate"); 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted May 6, 2019 Share Posted May 6, 2019 This one works. <?php add_hook('ClientAreaRegister', 1, function($vars) { $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI('AffiliateActivate', array('userid' => $vars['userid']), $adminUsername); }); Keep in mind that ClientAreaRegister hook point triggers only when customers register from register.php page. That means that if they're registering from cart.php while placing an order they are not activated as affiliates. Use ClientAdd if you want to activate them independently from what page they're registering. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.