Skip to content

Instantly share code, notes, and snippets.

@ascott
Created June 17, 2011 02:37
Show Gist options
  • Save ascott/1030750 to your computer and use it in GitHub Desktop.
Save ascott/1030750 to your computer and use it in GitHub Desktop.
wordpress - add a class to an element if user is admin
<?php
get_currentuserinfo(); 
//add_users is a capability only admins have - http://codex.wordpress.org/Roles_and_Capabilities#Administrator
if (!current_user_can( 'add_users' )) {
//set admin class
$adminclass = 'is_admin';
}
else {
$adminclass = '';
}
?>
<div class="<?php echo $adminclass; ?>">comment stuff</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment