Displaying Content Only For The Admin To See

May 6, 2008 · Print This Article

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.


Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.