• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Hide media sites from guests?

Janmaat

Active member
#1
Is it possible to hide media sites (like amazon and/or youtube links) from guests so that only registered users can see them?
 

Jeremy

Well-known member
#4
No. The parsing and display of the media tag doesn't utilize templates:
PHP:
    public function renderTagMedia(array $tag, array $rendererStates)
    {
        $mediaKey = trim($this->stringifyTree($tag['children']));
        if (preg_match('#[&?"\'<>\r\n]#', $mediaKey) || strpos($mediaKey, '..') !== false)
        {
            return '';
        }

        $mediaSiteId = strtolower($tag['option']);
        if ($mediaSiteId == 'youtube')
        {
            // youtube iframe embed bug workaround
            $mediaKey = str_replace('/', '', $mediaKey);
        }
        if (isset($this->_mediaSites[$mediaSiteId]))
        {
            $embedHtml = $this->_getMediaSiteHtmlFromCallback($mediaKey, $this->_mediaSites[$mediaSiteId]);

            if (!$embedHtml)
            {
                $embedHtml = strtr($this->_mediaSites[$mediaSiteId]['embed_html'], array(
                    '{$id}' => urlencode($mediaKey),
                    '{$id:digits}' => intval($mediaKey)
                ));
            }

            return $embedHtml;
        }
        else
        {
            return '';
        }
    }