countUsers

Counts the number of Users in an Account that match the search criteria.

countUsers

Counts the number of Users in an Account that match the search criteria.

Top ↑

Syntax

int countUsers(
    string api_key,
    int account_id,
  [ array search_criteria ] 
);

Parameters

api_key (string)

The key required to access the API. See Getting Started for more information.

account_id (int)

The Account ID.

search_criteria (array - optional)

An array of search criteria that selects the Users to be counted. See searchUsers for a description of the values which can be searched on.

Return Value

The number of Users in an Account that match the search criteria.

Examples

The following example counts the number of users in account 123456 with the username Tom and an email address with the domain gmail.

$api = new Api($url, 'YOURAPIKEY');

$search_criteria = array(
    array('email', 'contains', 'gmail'),
    array('username', 'contains', 'tom')
);

$account_users = $api->invokeMethod('countUsers', 123456, $search_criteria);
{
    "id": 1,
    "method": "countUsers",
    "params": [
        "YOURAPIKEY",
        123456,
        [
            [
                "email",
                "contains",
                "gmail"
            ],
            [
                "username",
                "contains",
                "tom"
            ]
        ],
    ]
}
{
    "id": 5,
    "result": 2,
    "error": null
}

Error Codes

This method may return the following error codes in addition to the standard error codes:

Code Error Description
321 Administrative access denied account_id does not belong to the Account Owner (the User who is attempting to access the API) or is not a sub-Account belonging to the Account Owner.
328 Unable to load Account account_id is not a valid account
328 Unable to load Account: Account has been deleted account_id is a deleted account
311 Invalid Search Parameter Format search_criteria is not valid

See Also