A big problem with WHMCS is that you don't have any API to manage customfields. With this API you can get all clients, products or support custom fields.
You can use it as a standard WHMCS API. You may want to use it with internal API function. In this case WHMCS documentation is helpful so no more explanations are required. Keep in mind that due to the way WHMCS handles API permissions, you will only be able to use this as internal API.
To use it you have to upload the getcustomfields.php (all lowercase) into the /includes/api whmcs folder and it's done.
$19 - Download NowParameter | Type | Description | Required |
---|---|---|---|
relid | int | The ID of the related item you want to get the custom fields for | Required |
type | string | Supports client, product or support. defaults to client | Optional |
Parameter | Type | Description |
---|---|---|
result | string | The result of the operation: success or error |
fieldname | Array | An array with all the data using the name of the field as the key of the Array |
fieldid | Array | An array with all the data using the id of the field as the key of the Array |
Given the recent changes in WHMCS custom API work only with the Local API function.
$command = 'GetCustomFields'; $postData = array( 'relid' => 1, ); $adminUsername = 'ADMIN_USERNAME'; $results = localAPI($command, $postData, $adminUsername); print_r($results);
Array ( [result] => success, [1] => Array ( [id] => 1 [fieldname] => custom field name [fieldtype] => text [description] => description [fieldoptions] => [regexpr] => [adminonly] => [required] => [showorder] => [showinvoice] => [value] => value [created_at] => 2019-01-19 18:00:00 [updated_at] => 2019-01-20 11:16:43 ) [custom field name] => Array ( [id] => 1 [fieldname] => custom field name [fieldtype] => text [description] => description [fieldoptions] => [regexpr] => [adminonly] => [required] => [showorder] => [showinvoice] => [value] => value [created_at] => 2019-01-19 18:00:00 [updated_at] => 2019-01-20 11:16:43 ) )
Error response codes are:
Got questions or problems? Contact us or comment, we'll be happy to help.