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
-
2It seems you haven't try to search this by yourself! Anyway read this post stackoverflow.com/questions/34037576/…– RishabhSep 29, 2016 at 7:40
-
i did but it doesnt work yet please tell me what do i exactlly to do?!– m.javad KoushkiSep 29, 2016 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-BrookSep 29, 2016 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 KoushkiSep 29, 2016 at 18:49
1 Answer
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, ) ); ?> Sep 29, 2016 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.– RishabhSep 30, 2016 at 5:21
-