• Resolved anabenne1

    (@anabenne1)


    Hello
    How can i display the users roles on page?

    i used this code, but its not working

    <?php 
    function is_user_role( $role, $user_id = null ) {
    $user = is_numeric( $user_id ) ? get_userdata( $user_id ) : wp_get_current_user();
    if( ! $user )
    return false;
    return in_array( $role, (array) $user->roles );
    }
    if( is_user_role( 'investor' ) )
    echo "investor";
    else
    echo "partner";
    ?>

    thanks!

    • This topic was modified 8 years, 5 months ago by anabenne1.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support mansurahamed

    (@mansurahamed)

    Hi @anabenne1 ,

    You can use wordpress function get_usermeta() for retrieving role of a user by user ID. for example

    get_usermeta($user_id,'role',true);

    If you want to show a list of all available role you can use following code

    global $ultimatemember;
    $roles = $ultimatemember->query->get_roles(); 

    Here $roles is an array containing all available roles.

    Thank you.

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Closed due to inactivity.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Display the users roles’ is closed to new replies.