Probably a silly question but can anyone advise on how I can save a JSON response to an extended modUser field?
I've created a field called 'clientid' and I have a JSON response that is
{
"result": "success",
"clientid": "1"
}
I've called the API and that seems to be working correctly but I'm not clear on how to save the clientid to the clientid field in MODX.
I've tried
****Bunch of CURL/API stuff*****
$jsonData = json_decode($response, true);
$profile->set('clientid', $jsonData['clientid']);
$profile->save();
Thanks!
[ed. note: lkfranklin last edited this post 9 years, 3 months ago.]
-
☆ A M B ☆
- 3,141 Posts
$profile->set('clientid') does not write to the extended field. As far as I know you'll need to do something like this:
$newExtended = array('clientid' => $jsonData['clientid']);
$extended = $profile->get('extended');
$extended = is_array($extended) ? array_merge($extended,$newExtended) : $newExtended;
$profile->set('extended',$extended);
$profile->save();
Thanks for the reply, Mark!
I should probably clarify that by extended user I meant that I used the classExtender from BobRay to create additional input fields, not the extended tab.
discuss.answer
I think, then you need to save into the userData - object. Not into the modProfile - object?
Hey guys
How to maintain clientid Please Help Me Out.. !!
Hi Carla,
We need *way* more information about exactly what you're trying to do and why in order to help you.