Forums

Get author role name (2 posts)

  1. Dennis
    Member
    Posted 5 months ago #

    Hello,
    I'm trying to make an "author" page for my blog and to make things easy I want to know if is possible to get the role name, for example:

    Dennis / <role> = Dennis / Editor

    Thanks,

  2. Take a look at Justin Tadlock's code:

    http://wordpress.org/support/topic/get-a-users-role-by-user-id?replies=20#post-1363118

    Not sure about author pages but in a loop that would be (ugly modification below)

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

    Once you have the $role output, you can clean it up and display Editor, Contributor, Cook, etc.

Reply

You must log in to post.

About this Topic