Jump to content

API - Add New Client - Setting Group ID Field


RPS

Recommended Posts

If you're using the API to add a new client to WHMCS, and would like to set the Group ID of that new client, here's how:

 

 

Grab the new client id from the result of creating a new client. This should be in the $results array, under clientid:

 

$set_groupid_result = mysql_query("UPDATE tblclients SET groupid='1' WHERE id='".$results['clientid']."' LIMIT 1");

 

You will need to login to the admin area to find out what the correct groupid is. In the above case, the groupid is 1.

 

You will also need to create a database connection in order to execute the MySQL command.

 

Here's the full script, given the clientid.

 

// include the connection details
include('/home/user/public_html/whmcs/configuration.php');

// connect to the database
$connectMe = @mysql_connect ($db_host, $db_username, $db_password);
// verify the connection took place
if(!(@mysql_select_db ($db_name)))
{
exit ('<p><b>Critical Error</b></p><p>Unable to connect to database</p>');
}

// set the correct groupid for the new user
$set_groupid_result = mysql_query("UPDATE tblclients SET groupid='1' WHERE id='".$results['clientid']."' LIMIT 1");

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