Page 1 of 1

Api user/create with _customfields fails

Posted: Thu Aug 11, 2022 8:08 pm
by fdougnac
Hello, I am using the api to create users and I have problems with the _customfields
It does not recognize these values ​​when creating the user
I do it this way:

$testApiCall = new SimpleXMLElement(FormaLMS::call('user/create', array(
'auth'=>$tokenforma,
'userid' => ‘user1’,
'firstname' => 'firstuser',
'lastname' => ‘userlast’,
'password' => 'prueba1',
'email' => ‘correo@gmail.com’,
'role' => "user",
'valid' => 1,
'force_change' => 0,
'_customfields' => [
5 => 'customfield5' ,
16 => ‘customfield16’
]
)));

Re: Api user/create with _customfields fails

Posted: Fri Aug 12, 2022 7:47 am
by alfa24
Other users found this bug. I solved in a custom instance, it's not simple because customfields should be decoded when passed as array in POST (multidimensional arrays cannot be passed as POSTFIELDS parameter when called in a cURL).
One solution is to use http_build_query to encode customfield array.
This would work for createuser and updateuser actions.
If you need help with code, you can contact me in private.