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

Only Show to Admins

Discussion in 'XenForo Development Discussions' started by LPH, Jul 25, 2013.

  1. LPH

    LPH Well-Known Member

    I'm building my first XenForo add-on and have manually set the Listener. The HTML code shows to everyone. I'd like to get this code to only show to admins. How do I wrap the echo so that only the admins see it?

    I know this is basic - so the question is - what is the best method for making sure this is only seen by admins?

    Maybe this approach is wrong, too. Please let me know if you can think of a better approach.

    * This is the view for showing html to admin

    class TuxReports_XenFeature_ViewAdmin_Promotes extends XenForo_Model
       public static function 
    showPromoteButton($hookName, &$contents, array $hookParamsXenFro_template_Abstract $template)
    $hookName == 'ad_above_content' )



         <div style="float:right; margin-top:-50px;"><button type="button">Promote</button></div>


    $contents .= ob_get_contents();

    The CSS is just temporary until other parts of the code are set.

    Update: Guess it would be helpful to give an idea ...

    Update 2:

    Update 3: This seems to work and only shows to admins but it's showing everywhere and will need to get it to simply show on the thread ...

    $visitor XenForo_Visitor::getInstance();
         if ( 
    $visitor['is_moderator'] AND $visitor['is_admin'] )
    Hope this helps someone else struggling with an XF add-on.
    Last edited: Jul 25, 2013
    Marcus likes this.
  2. Nobita.Kun

    Nobita.Kun Well-Known Member

  3. LPH

    LPH Well-Known Member

Share This Page