Lee
Well-known member
I have the following code:
I am looking to get the user entity of the user who is posting the message so I can load their custom_field "CharCode". At the moment I am loading the visitors value, which is not the outcome I want.
I guess I need to load the user entity by doing something like:
to make this data available, but how do I get the user ID of the posting user to get the right entity?
Thanks
PHP:
public static function renderChar(array $children, $option, array $tag, array $options, AbstractRenderer $renderer)
{
$output = trim($renderer->renderSubTree($children, $options));
$charCode = \XF::visitor()->Profile->custom_fields->CharCode;
return $renderer->wrapHtml(
'<div style="color: ' . $charCode . '">',
$output,
'</div>'
);
}
I am looking to get the user entity of the user who is posting the message so I can load their custom_field "CharCode". At the moment I am loading the visitors value, which is not the outcome I want.
I guess I need to load the user entity by doing something like:
PHP:
$userId = $attributes;
$user = \XF::em()->find('XF:User', $userId);
to make this data available, but how do I get the user ID of the posting user to get the right entity?
Thanks