Con le API di WHMCS possiamo ottenere i domini attivi di un cliente.

Possiamo implementare la seguente soluzione.


function get_client_active_domains($client_id) {
    $domains = [];

    if(!ctype_digit($client_id) || !filter_var($client_id, FILTER_VALIDATE_INT)) {
        return $domains;
    }
    $command = 'GetClientsDomains';
    $data = [
        'clientid' => $client_id,
        'limitnum' => 10000,
        'stats' => false
    ];
    $results = localAPI($command, $data);
    if($results['result'] !== 'success') {
        return $domains;
    }
    $client_domains = $results['domains']['domain'];
    if(count($client_domains) > 0) {
        foreach($client_domains as $client_domain) {
            if($client_domain['status'] === 'Active') {
                $domains[] = $client_domain;
            }
        }
    }
    return $domains;
}