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.
<?php /** * 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 } ?> |