I’m working on a site and I need to get the type of user the author is so I can mark it.

The idea is that if an Admin level user post something it has a [ADMIN] tag or something next to their name. I know how to compare things within php but how do I check to see what user type an author is if possible? I can’t seem to find any good documentation on the matter.

2 Answers
2

One way would be to use the get_the_author_meta function and pass it user_level

More info on the function: http://codex.wordpress.org/Function_Reference/get_the_author_meta

Then, see this chart to convert user levels to roles (unless you have created custom roles):
http://codex.wordpress.org/Roles_and_Capabilities#User_Level_to_Role_Conversion

Example code

$level = get_the_author_meta('user_level');

if($level >= 8) { // Is admin
    // do something
} else if ($level > 2 && $level < 8) { // is editor
    // do something else
}

Leave a Reply

Your email address will not be published. Required fields are marked *