Jump to content

Add new client with missing required fields


Thembi

Recommended Posts

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);

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated