From 6c8281392b42ef40feebf7575e68716986f72f8f Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Fri, 12 Feb 2021 13:35:03 +0100 Subject: [PATCH] Support guest users in UserFunctionTemplatePlugin Closes #3989 --- .../plugin/UserFunctionTemplatePlugin.class.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/lib/system/template/plugin/UserFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/UserFunctionTemplatePlugin.class.php index 3b5c4f8b98..dc9b42ef3f 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/UserFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/UserFunctionTemplatePlugin.class.php @@ -74,12 +74,14 @@ class UserFunctionTemplatePlugin implements IFunctionTemplatePlugin // default case if ($content === '') { - $additionalParameters = ' data-object-id="' . $object->getObjectID() . '"'; $content = $object->getFormattedUsername(); - if (isset($tagArgs['class'])) { - $tagArgs['class'] = 'userLink ' . $tagArgs['class']; - } else { - $tagArgs['class'] = 'userLink'; + if ($object->getObjectID()) { + $additionalParameters = ' data-object-id="' . $object->getObjectID() . '"'; + if (isset($tagArgs['class'])) { + $tagArgs['class'] = 'userLink ' . $tagArgs['class']; + } else { + $tagArgs['class'] = 'userLink'; + } } } @@ -102,6 +104,10 @@ class UserFunctionTemplatePlugin implements IFunctionTemplatePlugin . '="' . StringUtil::encodeHTML($value) . '"'; } + if (!$object->getObjectID()) { + return '' . $content . ''; + } + return '' . $content . ''; } } -- 2.20.1