Thembi Posted March 28, 2017 Share Posted March 28, 2017 How to add new client with Addclient API call without required fields/field like ('phonenumber') , and then force client to edit his/her details at this link 'clientarea.php?action=details#_=_' when user details are not complete. below is my code: $command = 'AddClient'; $postData = array( 'firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john.doe@example.com', 'address1' => '123 Main Street', 'city' => 'Anytown', 'state' => 'ST', 'postcode' => '12345', 'country' => 'US', 'phonenumber' => '', //without the phone number 'password2' => 'password', 'cardtype' => 'Visa', 'cardnum' => '4111111111111111', 'expdate' => '0721', 'clientip' => '1.2.3.4', ); $adminUsername = 'ADMIN_USERNAME'; $results = localAPI($command, $postData, $adminUsername); 0 Quote Link to comment Share on other sites More sharing options...
markhughes Posted March 29, 2017 Share Posted March 29, 2017 You don't actually have to use the localAPI for this anymore since WHMCS 6.0 You can use the WHMCS classes, its much nicer! $newClient = new \WHMCS\User\Client; $newClient->firstName = "John"; $newClient->lastName = "Doe"; $newClient->email = "john.doe@example.com"; $newClient->passwordHash = bcrypt("password"); // you have to hash the password //.. etc $newClient->save(); In regards to passwordHash if you are using PHP 5.3.7 or greater, then bcrypt will be used. If you are using PHP less than 5.3.7, SHA256-HMAC will be used. You can see all the fields you can set here: http://docs.whmcs.com/classes/7.1/WHMCS/User/Client.html 0 Quote Link to comment Share on other sites More sharing options...
markhughes Posted March 31, 2017 Share Posted March 31, 2017 Sorry the forum wont let me edit my post - you don't use bcrypt like that, you use it like this: $passwordHash = password_hash("password", PASSWORD_BCRYPT); 0 Quote Link to comment Share on other sites More sharing options...
Thembi Posted April 7, 2017 Author Share Posted April 7, 2017 Thank you very much mark 0 Quote Link to comment Share on other sites More sharing options...
markhughes Posted April 8, 2017 Share Posted April 8, 2017 Happy to help good luck! 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.