Hi,
I have a snippet that should save current resource id to current logged user extended value - this part does not work!
Apart of this it also save IP for non logged user - this part works!
Please help with non working part (does not save any value, extended value Quip exists)
<?php
$id = $modx->resource->get('id'); //current id
if ($modx->user->hasSessionContext($modx->context->get('key'))) {
// for logged users
// Get the user's extended fields
$profile = $modx->user->getOne('Profile');
$fields = $profile->get('extended');
$fields['Quip'] = $fields['Quip'] . $id . ',';
$profile->set('extended',$fields);
$profile->save();
}
else {
//not logged in, add ip to tv
$ip=$_SERVER['REMOTE_ADDR'];
$tv = $modx->getObject('modResource', $id);
$tvip = $tv->getTVValue('quip_ip') . $ip . ',';
$tv->setTVValue('quip_ip', $tvip);
}
$modx->cacheManager->refresh();
return true;