Display member user role in profile header
-
I’m working on adding the member’s user role in the header area of the Profile. I’ve pasted the code snippet I started from below, but this just returns the user role of the currently logged in user, so in my case it shows “Administrator” regardless of the member profile I’m looking at.
Can anyone suggest how to modify this so it returns the user role name of the profile displayed?add_action( 'um_after_header_meta', 'add_user_role', 10 );
function add_user_role() {
global $current_user;
$role = $current_user->roles[0];
$role_name = $role ? wp_roles()->get_names()[ $role ] : '';
echo '<div class="profile-role">',$role_name,'</div>';
}
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Display member user role in profile header’ is closed to new replies.