Skip to content

Instantly share code, notes, and snippets.

@splittingred
Created August 26, 2011 17:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save splittingred/1173958 to your computer and use it in GitHub Desktop.
Save splittingred/1173958 to your computer and use it in GitHub Desktop.
PreHook for FormIt to load User data into form
<?php
if (!$modx->user->hasSessionContext($modx->context->get('key')) return '';
$userArray = $modx->user->toArray();
$profile = $modx->user->getOne('Profile');
if ($profile) {
$userArray = array_merge($profile->toArray(),$userArray);
$extended = $profile->get('extended');
if (!empty($extended) && is_array($extended)) {
$userArray = array_merge($extended,$userArray);
}
}
$hook->setValues($userArray);
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment