aliitp Posted December 6, 2016 Share Posted December 6, 2016 I was having a conversation with support how to add multiple clients to whmcs at once from a text file with clients emails, they suggested the following to me:- Hey, I would recommend using the API AddClient. It would be easier to go this route since it will properly validate the data for you: <?php /** * This file will insert a new client * into the database using the AddClient * API call. * * @package WHMCS * @author WHMCS Chance * @copyright Copyright (c) WHMCS Limited 2005-2016 * @license https://www.whmcs.com/license WHMCS Eula * @link https://www.whmcs.com/ * @see http://docs.whmcs.com/API:Add_Client */ require 'init.php'; $request = localAPI( 'addclient', array( 'firstname' => 'Test', 'lastname' => 'User', 'email' => 'test@domain.tld', 'address1' => '123 Street Name', 'city' => 'City Name', 'state' => 'State', 'postcode' => '123abc', 'password2' => 'password', 'phonenumber' => '1234567890', 'country' => 'US' ), 'adminusername' ); echo "<pre>" . print_r($request, true) . "</pre>"; Simply create a file in your root WHMCS directory called addClient.php and copy and paste the above code into it. Save the file then you can modify the user data and change the adminusername to an actual admin username and save. Then run it via the browser and it will out put the results for you. Thanks! This worked fine for a single client, but as i was asking how to add ((Multiple)) clients the same time with the minimum info needed, at least client email and password as default: 123 for all clients ? they suggested the following:- Hey, You could place all the clients in a file, then have the script include the file and then loop through each of the clients from that file and have the script insert them all in one go. The fields I have provided in the script are the minimum required fields needed to create client accounts. I hope this helps. Thanks! then... Unfortunately I do not have an example of this written out. But essentially you would have a flat file like a text file or csv export file. You would have PHP pull in this file and then using a foreach or a while loop, have it run through all of the entries in that flat file, and process them through the API until it has completed looping through all of the data. For further assistance customising WHMCS feel free to consult with our friendly community of experts in our Customisation & Integration forum at http://forum.whmcs.com/ can anyone help out since I got a text file with 1 email per line and id like to add them to WHMCS, i got no good knowledge in programming so any help how this script would like id greatly appreciate it... thanks all... 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted December 6, 2016 Share Posted December 6, 2016 import file/script depend on what format your clients txt file have, you need to parse/render this data from text/csv file then run the API call in loop. 0 Quote Link to comment Share on other sites More sharing options...
aliitp Posted December 7, 2016 Author Share Posted December 7, 2016 import file/script depend on what format your clients txt file have, you need to parse/render this data from text/csv file then run the API call in loop. can this be done by adding only the email and default name "Client" ?? I tried that by editing the code above and only added:- 'firstname' => 'Test', 'lastname' => 'User', 'email' => 'test@domain.tld', all the rest of the info were not necessary at this point, and it did work absolutely fine, i don't think it should cause a problem if importing only email from a standard .txt file, I don't know how to do that unfortunately so i need a programmer's help... Thank you... 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.