Role Scoper
Get the user role in page template (2 posts)

  1. Jay Kanakiya
    Posted 3 years ago #

    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


  2. Kevin Behrens
    Plugin Author

    Posted 2 years ago #

    Documentation is not currently available, but this topic will point you to sample code.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Role Scoper
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic