benji
benji

Reputation: 681

custom fields not inserting using WHMCS API

I am trying to insert some extra client details using WHMCS API's 'add client'. However the insertion takes place , but the customfields gets no effect,when I checked in WHMCS client area.I have customfield[1],[2]...[5] added as fields in client area.The code snippet is as follows

$postfields["action"] = "addclient"; 

$customfields = array(
'customfield[1]' => "ABC",
'customfield[2]' => "XYZ"
);

$postfields["customfields"] = base64_encode(serialize($customfields)

Please suggest a solution.

Upvotes: 2

Views: 4391

Answers (2)

Mahmudul
Mahmudul

Reputation: 11

The following should solve the issue:

$customfields = array( '1' => "ABC", '2' => "XYZ" );
$postfields["customfields"] = base64_encode(serialize($customfields)

Upvotes: 1

benji
benji

Reputation: 681

I have solved the problem.

I just changed

$customfields = array(
'customfield[1]' => "ABC",
'customfield[2]' => "XYZ"
);

$postfields["customfields"] = base64_encode(serialize($customfields)

into

$postfields["customfield[1]"] = "ABC";
$postfields["customfield[2]"] = "XYZ";

Upvotes: 6

Related Questions