Not getting anywhere with this. The added field in the form works and it’s value is available here.
With this code, the setting is created but the user ID is 0 and the key is blank (other fields, including the value, are correct):
case 'OnUserFormSave':
$user = $id;
if (! empty($_POST['TreeRoot'])) { $userSetting = $modx->newObject('modUserSetting', array(
$userSettiing->set('user'=>$user),
$userSettiing->set('key'=>'tree_root_id'),
$userSettiing->set('value'=>$_POST['TreeRoot']),
$userSettiing->set('namespace'=>'core'),
));
$userSetting->save();
}
This code just hangs when you save the form (the "saving" progress bar never goes away). The setting is not created.
case ’OnUserFormSave’:
$user = $id;
if (! empty($_POST['TreeRoot'])) { $userSetting = $modx->newObject('modUserSetting');
$userSettiing->set('user',$user);
$userSettiing->set('key','tree_root_id');
$userSettiing->set('value',$_POST['TreeRoot']);
$userSettiing->set('namespace','core');
$userSetting->save();
}
break;