From inside a comment Loop…
$author_data = get_user_by('login',$comment->comment_author);
if (!empty($author_data)) {
var_dump($author_data->roles);
}
$author_data->roles
is an array so you will need to work out what you want to do with that. That is, print them all? Print the highest ranking role?
if (array_intersect(array('administrator','moderator'),$author_data->roles)) {
echo 'admin';
} elseif (array_intersect(array('something','else'),$author_data->roles)) {
echo 'something else';
}
Related Posts:
- How to add internal, revision comments to page updates
- What’s the easiest way to close comments on media/attachments?
- Comments Feed & Custom Post Statuses
- Send Notifications to All Admins
- Report spam button
- Filter In Reply comments from WordPress Admin Panel
- warnCommentChanges always being triggered on update
- How do I disable the discussion notification emails to us when a comment is “approved” and when an adiministrator replies?
- Admin Dashboard – Recent Comments source
- Styling Admin comments in WP 3.1.3
- Prevent users to delete comments from trash
- How do I add custom field to Admin comment form and display
- Comments counter only for Authors Posts
- where can I find the missing comments in my wordpress dashboard?
- How to enable reply button on mostly deeply-nested comments? [closed]
- How to ‘If Author’ Comments Check
- Show ‘add comment’ link for status updates in Twenty Thirteen
- edit-comments.php in Admin – how to change ‘Comments’ title?
- Query comments with non-empty ‘author_url’ value on Admin Comments Screen
- Add option to disable comments on a per posts basis?
- Paginate result set from $wpdb->get_results()
- What should I do to make generated avatars different for anonymous comments?
- Check If comment author is registered
- Success message in comment form
- How to allow the reply link to remain on the comment form after I have reached my 10 nested comment limit?
- Threaded comments – deleting parent comment leads to orphan comments
- Is there a hook for comment author link?
- How can I edit the email sent when a new comment is received?
- How to remove or replace the log-in link for comment replies?
- How to Block Access to Standard Login Flow and Comment Flow
- Add Comment Custom Field
- Remove link preview in discussion dashboard
- Upload images with comment
- Prevent Contributor to show comment list
- where to modify get_comment_author_link()?
- Does Akismet plugin expose any hooks, functions, class that can work with custom code?
- Hiding by default specific post status on backend list?
- WordPress comment count to include attachment comments
- Displaying comments with a walker: how to distinguish between parent and child comments
- Count parent comments & replies separately?
- How to modify comments form using comment_form()?
- Capability for allowing user to post own comments without moderation
- Comment form problem with comment_author_url and HTML5 input placeholders
- How would I count the number of times a comment meta field’s value is in a post’s entire comments?
- stackexchange-like submit comment window
- Cannot get local avatars to show [closed]
- Limit user to one comment
- WordPress comments on users profile
- wordpress threaded comments – customize nested ul / how child ul is displayd
- How to make a secure blog that is completely private?
- identify and delete spam comments from 3000 pending comments
- Hide comments column in WordPress backend
- How unrequire comment text in wordpress post
- Auto delete comment if Contains
- How would I add the comment count to this sub-pages of current page snippet
- How can I test why the comment hook is not working?
- API Hook for After Commenting (for sharing on Facebook)
- How do i remove “Website” field from WordPress comments
- Can comments by a logged-in user be displayed at the top?
- Placed on + only date (not time)
- Loading Comments From a Class?
- have_comments not true for logged out visitors?
- Anonymize comments after one year
- How can I count only guests comments?
- How many members have made comments approved for an article?
- How to get a value from comment meta
- reCaptcha doesnt appear in comment (manual or plugin)
- Comment System showing different type of IP
- Pending Comments
- Only Allow post author and “Premium” Role user to comment
- Exclude the word comment from being referenced
- How to open up comments to all visitors
- Limit iframe output in comment-meta commentmetadata
- What is the earliest hook comment meta can be saved?
- Is this a wordpress bug? get_comment_link auto shoots when user visits his dashboard
- Comment as post – understanding wp_list_comments
- Comments and pingbacks issues
- Cannot unapprove a WordPress comment
- how show attachment image in comments query
- Automatically register users with comments
- Comments only displaying when logged in
- Same comment section on every page
- reply comment below the comment box without reload page
- Force to show all fields in comment forms to the logged-in users
- Unable to view comments on my website
- Using WordPress core pop-up comment function, doesn’t popup, maybe an elementor issue
- Comments editor not rendering   and tag
- How to call out the date of user’s first comment?
- comment_moderation_subject is not working for me
- How do you remove the ability for a user to make a comment or post on a page?
- wp_trash_post retrashes already trashed comments?
- wp_insert_user email confirmation
- Comments appear in wrong posts
- Subscribe to a post’s comments without posting a comment yourself
- WordPress error when sending comment
- WordPress Page Template: Comment Filtering with Querystring
- comments are going to spam
- Why default comment fields don’t show up?
- How to enable truly anonymous posting in bbPress forums? [closed]
- TinyMCE in comment reply form showing toolbar but can’t edit reply