Support » Plugin: Role Scoper » Get the user role in page template

  • I have got a page template where I would like to show all the users with their current role defined in the role Scaper.
    Here is the php code

    		$authors = $wpdb->get_results('SELECT DISTINCT post_author FROM '.$wpdb->posts);
    		foreach($authors as $author):
    		<div class='author' id='author-<?php the_author_meta('user_login', $author->post_author); ?>'>
    			<h3><?php the_author_meta('display_name', $author->post_author); ?></h3>
    			<div class='description'>
    				<?php echo get_avatar(get_the_author_meta('user_email', $author->post_author), 80); ?>
    				<p><?php the_author_meta('description', $author->post_author); ?></p>
    				<p><?php the_author_meta('number', $author->post_author); ?></p>
    					$user = new WP_User( $author->post_author);
    				if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
    				foreach ( $user->roles as $role )
    					echo $role." ";

    The display names and others perfectly but the echo $role gives output as administrator , contributor not the semantic names I’ve assigned in role scoper

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Get the user role in page template’ is closed to new replies.