Basically I want the value of a TV (a.k.a. Template Variable) to default to the value of a user's extended field. I tried making a snippet named get_author
with the following content:
$user = $modx->getUser();
if (!$user) return '';
$profile = $user->getOne('Profile');
if (!$profile) return '';
$extended = $profile->get('extended');
return(isset($extended['author_page'])) ? $extended['author_page'] : '';
And add the following code to a TV's default value property:
@EVAL return $modx->runSnippet('get_author');
It looks like the code itself works, but the value doesn't default to the desired value until the user clicks the 'set to default' button in the manager. But when I fill in a static value like 8
(so without the @eval
) the value immediately defaults on form load. Can anyone tell me how this has to be done?
Thanks in advance!