Posted By

vagrantradio on 08/13/10


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jamalmohamed


Show/Hide Content Based On User Role in WordPress


 / Published in: PHP
 

Customize as needed using user roles.

  1. <?php if (is_user_logged_in() ) { //only logged in user can see this ?>
  2. <div><p>You are logged in!</p></div>
  3. <?php } ?>
  4.  
  5. <?php if ( current_user_can( 'delete_others_posts' ) ) { //only admins and editors can see this ?>
  6. <p>You are an admin</p>
  7. <?php } else { ?>
  8. <p>You are not an admin</p>
  9. <?php } ?>

Report this snippet  

You need to login to post a comment.