cPanel is a cool software and allows you to automate many things.

If you want to check if a username exists you can use accountsummary API call.

 

$ip = "127.0.0.1"; // should be server IP address or 127.0.0.1 if local server
$port = 2087; // cpanel secure authentication port unsecure port# 2082
$cp_username = 'user';
$cp_passwd = 'pass';

$username = 'some_cpanel_user';

$xmlapi = new xmlapi($ip);
$xmlapi->set_port($port);  //set port number. cpanel client class allow you to access WHM as well using WHM port.
$xmlapi->password_auth($cp_username, $cp_passwd);   // authorization with password. not as secure as hash.
$xmlapi->set_debug(1);      //output to error file  set to 1 to see error_log.

$xml_res = $xmlapi->accountsummary( $username );

$yes = ! empty( $xml_res->status );

Response

object(SimpleXMLElement)#3 (3) {
  ["acct"]=>
  object(SimpleXMLElement)#4 (31) {
    ["backup"]=>
    string(1) "0"
    ["disklimit"]=>
    string(9) "unlimited"
    ["diskused"]=>
    string(2) "0M"
    ["domain"]=>
    string(26) "orbisius.com"
    ["email"]=>
    string(9) "*unknown*"
    ["ip"]=>
    string(13) "1.2.3.4"
    ["is_locked"]=>
    string(1) "0"
    ["legacy_backup"]=>
    string(1) "0"
    ["max_defer_fail_percentage"]=>
    string(9) "unlimited"
    ["max_email_per_hour"]=>
    string(9) "unlimited"
    ["maxaddons"]=>
    string(9) "*unknown*"
    ["maxftp"]=>
    string(9) "*unknown*"
    ["maxlst"]=>
    string(9) "unlimited"
    ["maxparked"]=>
    string(9) "*unknown*"
    ["maxpop"]=>
    string(9) "unlimited"
    ["maxsql"]=>
    string(9) "unlimited"
    ["maxsub"]=>
    string(9) "unlimited"
    ["min_defer_fail_to_trigger_protection"]=>
    string(1) "5"
    ["outgoing_mail_hold"]=>
    string(1) "0"
    ["outgoing_mail_suspended"]=>
    string(1) "0"
    ["owner"]=>
    string(5) "weeuu"
    ["partition"]=>
    string(4) "home"
    ["plan"]=>
    string(11) "weeuu_plan1"
    ["shell"]=>
    string(29) "/usr/local/cpanel/bin/noshell"
    ["startdate"]=>
    string(15) "16 Apr 29 17:40"
    ["suspended"]=>
    string(1) "0"
    ["suspendreason"]=>
    string(13) "not suspended"
    ["suspendtime"]=>
    string(1) "0"
    ["theme"]=>
    string(13) "paper_lantern"
    ["unix_startdate"]=>
    string(10) "1461966001"
    ["user"]=>
    string(2) "w1"
  }
  ["status"]=>
  string(1) "1"
  ["statusmsg"]=>
  string(2) "Ok"
}

 

Related links:

Referral Note: When you purchase through a referral link (if any) on this page, we may earn a commission.
If you're feeling thankful, you can buy me a coffee or a beer