I'm trying to take a user's extended field, which actually contains an array, turn it into a string, then pass to a placeholder. The snippet is part of a posthook on the UpdateProfile extra.
Even through I have something similar working elsewhere, I can't get this to work. My placeholder only displays the last value (in this case "UK"). Grateful for any help.
An example of the extended field from the modx_user_attributes database: "Location":["Spain","Switzerland","UK"],
The snippet code I'm using:
// get user profile
$profile = $modx->user->getOne('Profile');
// get user extended field values
$extended = $profile->get('extended');
// turn the array into a string
$userlocation = $extended['Location'];
$userlocations = implode(",", $userlocation);
// set placeholder
$modx->setPlaceholder('Location2','$userlocations');
return true;
to output to placeholder [[+Location2]]