Fixed Guest user group id are hard coded

TickTackk

Well-known member
Affected version
XF 2.x
In file path: src\XF\Template\Templater.php
Find inside fnUserTitle():
PHP:
                $guestGroupId = 1;
                if (empty($this->groupStyles[$guestGroupId]['user_title']))
                {
                    return '';
                }
Replace with:
PHP:
                $guestGroupId = \XF\Entity\User::GROUP_GUEST;
                if (empty($this->groupStyles[$guestGroupId]['user_title']))
                {
                    return '';
                }

Find inside fnUsernameClasses()
PHP:
        if ($includeGroupStyling)
        {
            if (!$user || empty($user['user_id']))
            {
                $displayGroupId = 1;
            }
            else
            {
Replace with:
PHP:
        if ($includeGroupStyling)
        {
            if (!$user || empty($user['user_id']))
            {
                $displayGroupId = \XF\Entity\User::GROUP_GUEST;
            }
            else
            {
 
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.0 B7/RC1).

Change log:
Reference the guest group constant instead of a magic number in several places.
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Top Bottom