[resolved] Total beginner - display html only to admisn (2 posts)

  1. rejemy
    Posted 8 years ago #

    Hello, sorry for the rudimentary question but I couldn't find anything in the docs, and I'm not a php programmer so I don't know how to go digging through the source to answer my own question-

    How can I mark up a template to display something only to admins? I want some links and information in my sidebar that is only displayed when you are logged in as an admin.

    Sorry if it's documented somewhere and I missed it! Thanks,


  2. Adam Brown
    Posted 8 years ago #

    Try something like this:

    <?php global $userdata;
          if ($userdata->user_level >= 8 ){
    <!-- html only admins will see -->
          } // this ends the "if" statement

    Making sure user_level is at least 8 limits the html to admins only. If you also want lower-level people (like editors) to see the html, use a lower number. Details are here: http://codex.wordpress.org/Roles_and_Capabilities#Role_to_User_Level_Conversion

Topic Closed

This topic has been closed to new replies.

About this Topic