Last active
September 18, 2018 05:29
-
-
Save mdjwel/3341bbaa976ebd4c8e648991928568c2 to your computer and use it in GitHub Desktop.
Get the user role in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function prefix_user_role() { | |
$user_meta = get_userdata(get_the_author_meta( 'ID' )); | |
$user_roles = $user_meta->roles; //array of roles the user is part of. | |
echo !empty($user_roles[0]) ? $user_roles[0] : ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment