1. 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?

Discussion in 'XenForo Questions and Support' started by Janmaat, Oct 17, 2013.

  1. Janmaat

    Janmaat Active Member

    Is it possible to hide media sites (like amazon and/or youtube links) from guests so that only registered users can see them?
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    You'll need a custom add-on to modify the out put dynamically.
     
    Janmaat likes this.
  3. Amaury

    Amaury Well-Known Member

    Couldn't conditionals work?
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    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 
    '';
            }
        }
     
    Amaury likes this.

Share This Page