In my wordpress website, there is a comment template in which I made some changes which I want, but I am having an issue.
Note : I am using the User Role Editor plugin.
I want to display user role next to the username in each comment.
My Code :
function get_the_author_role() {
global $wpdb, $wp_roles, $authordata;
if ( !isset($wp_roles) )
$wp_roles = new WP_Roles();
foreach($wp_roles->role_names as $role => $Role) {
$caps = $wpdb->prefix . 'capabilities';
if (array_key_exists($role, $authordata->$caps))
return $Role;
}
}
/**
* Echo the account role of the author of the current post in the Loop.
* @see get_the_author_role()
* @return null
*/
function the_author_role() {
echo get_the_author_role();
}
I added this code into function.php but it didn't work.
Here is my comment-template.php section :
<?php printf( __( ' <cite class="user" ><font size="5.5" color=red >
You can use:
Hope this helps :-)