A dedicated snippet will be much faster because the output modifier won't have to be parsed, and the user object won't need to be retrieved. I assume that your tag is in a Tpl chunk, since you're using getResources. You need to user + for the createdby tag, not *. Using * will get you the user who created the page with the getResources tag, not the blog post.
This is a particularly fast way to do it:
[[!GetCreatedbyFullname? &createdby=[[+createdby]] ]]
/* GetCreatedbyFullname snippet */
$userId = $modx->getOption('createdby', $scriptProperties);
$query = $modx->newQuery('modUserProfile', array('internalKey' => $userId);
$query->select('fullname');
$output = $modx->getValue($query->prepare());
/* optional - use the username as a backup if the full name is empty */
if (empty($output)) {
$query = $modx->newQuery('modUser', $userId);
$query->select('username');
$output = $modx->getValue($query->prepare());
}
/* end of optional section */
return $output;
The optional section will slow things down by a few milliseconds, but it won't execute if the full name is found. If you don't use the optional section, make sure every user has a full name in their profile.
[ed. note: BobRay last edited this post 11 years, 1 month ago.]