• I am looking for a way to display a user’s ‘role’ on their profile page.

    I want to grant a specific role to users, and have that role displayed on the ‘user list’ page and in their profile, so other users can see who has been ‘promoted’

    I have looked everywhere, including snippets, but cannot find anything that specifically addresses this issue. Any help would be appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    You can display the current user role in front-end using this code-

    $user_id = get_current_user_id();
    $user = new WP_User( $user_id );
    
    if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
    foreach ( $user->roles as $role )
    echo $role;
    }

    Regards

    Thread Starter gw808092

    (@gw808092)

    @makewebbetter Thank you so much. please where should i paste this code?

    Like a snippet or?

    Hi,

    You can write this code in the front end file in a function, where you want to display the current user role.

    Regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to display user role in user profile’ is closed to new replies.