FH-Vlad Posted January 18, 2013 Share Posted January 18, 2013 Hi guys, I am working on server module for integration with CCP. So far so good ... everything works as it should except one thing - saving back custom fields using internal api call. Here are the details ... PHP code to call api: $values3['clientid'] = $params['clientsdetails']['userid']; $values3["customfields"] = base64_encode( serialize( array( "CCP_username"=>$newuser ) ) ); $result3 = localAPI( "updateclient", $values3 , WHMCS_ADMIN ); Right after that I had the content of arrays emailed to me. Here they are: Values ( [clientid] => 11 [customfields] => YToxOntzOjEyOiJDQ1BfdXNlcm5hbWUiO3M6MTU6InZsYWRpbWlyLTExLTcxNCI7fQ== ) Result ( [result] => success [clientid] => 11 ) If you decode customfields, you'll get: "a:1:{s:12:"CCP_username";s:15:"vladimir-11-714";}" So ... the api call went through without error. But when I check user 11 in WHMCS admin panel, the custom field "CCP_username" is empty. I have looked into the database to see what happened. Here's the "CCP_username" in tblcustomfields dump: ... (12,'client',0,'CCP_username','text','CCP Username','','','on','','on','on',0) ... And here's what was generated in tblcustomfieldsvalues after that api call: ... (0,11,'vladimir-11-714') ... Now ... shouldn't that be (12,11,'vladimir-11-714') ? Obviously, something is not right ... either I am doing something wrong or there's a bug. WHMCS had been updated sometime late December to 5.1.2. Any comment ? 0 Quote Link to comment Share on other sites More sharing options...
FH-Vlad Posted January 18, 2013 Author Share Posted January 18, 2013 BTW, changing PHP code to base64_encode( serialize( array( "12"=>$newuser ) ) ); WORKS and custom field is properly populated. However ... I am pretty sure it was not meant to be used that way. 0 Quote Link to comment Share on other sites More sharing options...
openmind Posted January 21, 2013 Share Posted January 21, 2013 It is the way it's supposed to be used, look at the example for the Add Order command and you will see it's the same: http://docs.whmcs.com/API:Add_Order However, I do agree that it's a stupid method to use as you would have know the unique ID of the field to update it and there is no call to actually map the ID to a friendly name. 0 Quote Link to comment Share on other sites More sharing options...
WHMCS JamesX Posted January 21, 2013 Share Posted January 21, 2013 There can be multiple fields with the same name, and in addition to that, names can be changed. However, its ID wouldn't change just because its name has. 0 Quote Link to comment Share on other sites More sharing options...
openmind Posted January 21, 2013 Share Posted January 21, 2013 I don't disagree but there needs to be a call to at least lookup the IDs for a custom field within a product. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.