How-to and Troubleshooting
3
Posts
2
Users
0
Reactions
350
Views
Jun 01, 2024 4:32 pm
Hello,
is it possible to insert a small icon / image after the username for a specific role (registered user)?
I can change the CSS file, but I can't find where the query for the different roles is.
Thanks for the help.
Stefan
Website URL
2 Replies
Jun 05, 2024 10:45 am
Hi,
You can use the hook code below:
add_filter("wpdiscuz_after_comment_author", function ($html, $comment, $user) { if (!empty($user->ID) && !empty($user->roles) && is_array($user->roles)) { if (in_array('author', $user->roles)) { // if user has the role : author $html .= ' <img src="https://www.svgrepo.com/show/13644/avatar.svg" width="18" height="18" />'; } else if (in_array('editor', $user->roles)) { // if user has the role : editor } // and so on.. } return $html; }, 10, 3)
Please note it's just an example you should customize it.
Jun 05, 2024 12:22 pm
Great! Thank you!