How to check if the logged in user is subscriber or not in WordPress?

Following codes can be used to check if the logged in user is subscriber or not.

<?php
global $current_user; // Use global
get_currentuserinfo(); // Make sure global is set, if not set it.
if ( ! user_can( $current_user, "subscriber" ) ) // Check user object has not got subscriber role
    echo 'User is a not Subscriber';
else
    echo 'User is a Subscriber';
?>

0 comments:

Feel free to contact the admin for any suggestions and help.