Get a user’s role by user ID (in comments)
-
Hi!
I’m using this function to display the author role:
https://core.trac.www.ads-software.com/attachment/ticket/5290/author-template-the_author_role.difffunction 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(); }
(founded here)
and now, I would like to display the author role on comments (like on this wordpress support site); when using this function, it show the same role for all comments ( because it’s in reality the role of the author of the commented post).
What can I do?Thanks
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Get a user’s role by user ID (in comments)’ is closed to new replies.