conecta6 Posted April 7, 2017 Share Posted April 7, 2017 Hi i have a addclient hook that work perfectly in whmcs, but when i add a client width api internal call this hook is executed twiced. Why this? call code $command = 'AddClient'; $postData = array( 'firstname' => 'prueba', 'lastname' => 'Doe', 'email' => 'xxx@gmail.cohmx', 'address1' => '123 Main Street', 'city' => 'Anytown', 'state' => 'ST', 'postcode' => '12345', 'country' => 'US', 'phonenumber' => '800-555-1234', 'password2' => 'password', 'cardtype' => 'Visa', 'cardnum' => '4111111111111111', 'expdate' => '0721', 'clientip' => '46.26.45.24', ); $adminUsername = 'xxxx'; $results = localAPI($command, $postData, $adminUsername); hook code add_hook( 'ClientAdd', 1, function ($vars) { $userid = $vars['userid']; //insertamos dos puntos en el departamento de diseño $insertar= Capsule::table('mg_SupportTicketsLimiter_clients')->insert( ['department_id' => '6', 'client_id' => $userid, 'points' => '2' ] ); } ); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 7, 2017 Share Posted April 7, 2017 from the ClientAdd hook documentation... This hook is run when adding a new client. It doesn't matter how the client is added - can be via the admin area, client side signup or API - the hook will always be called. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted April 7, 2017 Share Posted April 7, 2017 to avoid the duplication, check if the record already in table then insert it 0 Quote Link to comment Share on other sites More sharing options...
markhughes Posted April 8, 2017 Share Posted April 8, 2017 It shouldn't be getting called twice though, this sounds like a bug. Are you sure you don't have duplicate code anywhere? 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.