Roughly four months ago I talked a bit about how to set up your blog so only the admin can see an edit button on blog posts. For whatever reason, I’ve always set this up on each of my websites and really get a lot of use out of it. Much along those same lines, Michael of WPCandy has written a post explaining how to display content so only the admin can view it. This goes well beyond the edit button and allows you to setup just about anything to display for the admin.

In hist post, Michael provides some code that looks at the user id to determine if the user has admin privileges and then displays whatever you tell it to for that user. Here is the code:

<?php global $user_ID; if( $user_ID ) : ?>
<?php if( current_user_can('level_10') ) : ?>
<a href="http://yourdomainurl.com/stats/">Stats</a>
<?php else : ?>

<?php endif; ?>
<?php endif; ?>

If you run a multi-author blog and would like to make this stuff available to editors, authors, contributors, and more, you can easily adjust the user level to determine who sees your display.

Great find Michael!

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Follow Kyle on Twitter @KyleEslick!

  1. Mike Smith says:

    I read that same post over at WPCandy.com and expanded on it as well to help with a blogs user experience.

    http://wordpresshut.com/display-user-welcome-message/

    Just thought I’d stop in and point you to it. Definitely limitless at the possibilities if offers.

  2. viettut says:

    I Know there is a Plugin to do that: HidePost Plugin which will hide content, link from post for all who below user level you was specify.