Home » Labs » How to Check User Role in WordPress  

How to Check User Role in WordPress

Filed under Labs

If you are a WordPress developer then sometimes you need to check a role of a user, for example you want to show particular link to only for registered authors and not for common visitors then the bellow WordPress snippet will help you fine.

 * Check User Role in WordPress
if( current_user_can('editor') ) {
    // true if user is an editor
if( !current_user_can('administrator') ) {
    // true if user is not admin
if( current_user_can('edit_posts') ) {
    // true if user can edit posts
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook

Posts you may like: