XF 2.2 PHP - Get User Banner

Majdev

Member
Hello Developers, I want to shoot users' banners, but I don't know how. With the help of the code below, I can pull the avatars without any problems, but when I use getBannerUrl I get an error. Isn't there a getBannerUrl method? if so how can i use it?

Error:
Code:
An exception occurred: [Error] Call to undefined method XF\Entity\User::getBannerUrl() in ....

My avatar method:
PHP:
    function GetAvatar($UserID){
        \XF::start('/hc');
        $Finder = \XF::finder('XF:User');
        $User = $Finder->where('user_id', $UserID)->fetchOne();
        $AvatarUrl = "default";
        if ($User->avatar_date || $User->gravatar) {
            $AvatarUrl = \XF::app()->request()->convertToAbsoluteUri($User->getAvatarUrl('l', null, true ));
        }
        return $AvatarUrl;
    }
 
Solution
Solved :)
Code:
src\XF\Entity\UserProfile.php : public function getBannerUrl($sizeCode, $canonical = false)
PHP:
    function GetBanner($UserID){
        \XF::start('/hc');
        $Finder = \XF::finder('XF:UserProfile');
        $User = $Finder->where('user_id', $UserID)->fetchOne();
        $BannerUrl = "default";
        if ($User->banner_date) {
           $BannerUrl = \XF::app()->request()->convertToAbsoluteUri($User->getBannerUrl('l'));
        }
        return $BannerUrl;  
    }

Majdev

Member
Solved :)
Code:
src\XF\Entity\UserProfile.php : public function getBannerUrl($sizeCode, $canonical = false)
PHP:
    function GetBanner($UserID){
        \XF::start('/hc');
        $Finder = \XF::finder('XF:UserProfile');
        $User = $Finder->where('user_id', $UserID)->fetchOne();
        $BannerUrl = "default";
        if ($User->banner_date) {
           $BannerUrl = \XF::app()->request()->convertToAbsoluteUri($User->getBannerUrl('l'));
        }
        return $BannerUrl;  
    }
 
Solution
Top