0

how can i show user's role in comment form near their name?!! for example when admin reply a comment i want to show "admin" word near admin name or when a user buy a product from my site and send a comment i want to show "buyer" role in near name enter image description here

  • 2
    It seems you haven't try to search this by yourself! Anyway read this post stackoverflow.com/questions/34037576/… – Rishabh Sep 29 '16 at 7:40
  • i did but it doesnt work yet please tell me what do i exactlly to do?! – m.javad Koushki Sep 29 '16 at 10:02
  • What exactly have you already done? Without seeing what you've attempted for yourself it is hard to offer help. You might find How to Ask useful. – Andy Macaulay-Brook Sep 29 '16 at 10:30
  • i dont anything because i dont know.just know i need add something to comments.php file to display user role – m.javad Koushki Sep 29 '16 at 18:49
1

This will print User Role

global $current_user;
$user_role = $current_user->roles[0];
echo $user_role;

Use above code, where ever you want to display user role.

  • i want display in comment form and the problem is i cant access to comment list because in comment form for display comments used this function <?php wp_list_comments( array( 'reply_text' => '', 'avatar_size' => 80, ) ); ?> – m.javad Koushki Sep 29 '16 at 18:48
  • It would be better if you show your code so someone can help you! Its hard to offer help without seeing any code. – Rishabh Sep 30 '16 at 5:21
  • i use default comments.php file for my theme – m.javad Koushki Sep 30 '16 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.